Functions to control remote GPIO and boot wait for network aligned with the rest.

This commit is contained in:
spl 2016-05-25 13:53:55 +01:00
parent 59649e8ba7
commit 5fece9527a

View File

@ -845,7 +845,7 @@ do_boot_behaviour() {
fi fi
} }
get_boot_slow() { get_boot_wait() {
if test -e /etc/systemd/system/dhcpcd.service.d/wait.conf; then if test -e /etc/systemd/system/dhcpcd.service.d/wait.conf; then
echo 0 echo 0
else else
@ -853,40 +853,39 @@ get_boot_slow() {
fi fi
} }
do_wait_for_network() { do_boot_wait() {
get_init_sys get_init_sys
if [ $SYSTEMD -eq 0 ]; then if [ $SYSTEMD -eq 0 ]; then
whiptail --msgbox "This option can only be selected when using systemd" 20 60 2 whiptail --msgbox "This option can only be selected when using systemd" 20 60 2
return 1 return 1
fi fi
if [ "$INTERACTIVE" = True ]; then
RET=$(whiptail --menu "Choose boot option" 20 70 10 \ DEFAULT=--defaultno
"Fast" "Boot without waiting for network connection" \ if [ $(get_boot_wait) -eq 0 ]; then
"Slow" "Wait for network connection before completing boot" \ DEFAULT=
3>&1 1>&2 2>&3)
else
get_init_sys
RET=$1
true
fi fi
if [ $? -eq 0 ]; then if [ "$INTERACTIVE" = True ]; then
case "$RET" in whiptail --yesno "Would you like boot to wait until a network connection is established?" $DEFAULT 20 60 2
Fast) RET=$?
rm -f /etc/systemd/system/dhcpcd.service.d/wait.conf else
;; RET=$1
Slow) fi
mkdir -p /etc/systemd/system/dhcpcd.service.d/ if [ $RET -eq 0 ]; then
cat > /etc/systemd/system/dhcpcd.service.d/wait.conf << EOF mkdir -p /etc/systemd/system/dhcpcd.service.d/
cat > /etc/systemd/system/dhcpcd.service.d/wait.conf << EOF
[Service] [Service]
ExecStart= ExecStart=
ExecStart=/sbin/dhcpcd -q -w ExecStart=/sbin/dhcpcd -q -w
EOF EOF
;; STATUS=enabled
*) elif [ $RET -eq 1 ]; then
whiptail --msgbox "Programmer error, unrecognised option" 20 60 2 rm -f /etc/systemd/system/dhcpcd.service.d/wait.conf
return 1 STATUS=disabled
;; else
esac return $RET
fi
if [ "$INTERACTIVE" = True ]; then
whiptail --msgbox "Waiting for network on boot is $STATUS" 20 60 1
fi fi
} }
@ -898,7 +897,7 @@ get_rgpio() {
fi fi
} }
do_gpiosec() { do_rgpio() {
get_init_sys get_init_sys
if [ $SYSTEMD -eq 0 ]; then if [ $SYSTEMD -eq 0 ]; then
whiptail --msgbox "This option can only be selected when using systemd" 20 60 2 whiptail --msgbox "This option can only be selected when using systemd" 20 60 2
@ -906,10 +905,8 @@ do_gpiosec() {
fi fi
DEFAULT=--defaultno DEFAULT=--defaultno
CURRENT=0
if [ $(get_rgpio) -eq 0 ]; then if [ $(get_rgpio) -eq 0 ]; then
DEFAULT= DEFAULT=
CURRENT=1
fi fi
if [ "$INTERACTIVE" = True ]; then if [ "$INTERACTIVE" = True ]; then
whiptail --yesno "Would you like the GPIO server to be accessible over the network?" $DEFAULT 20 60 2 whiptail --yesno "Would you like the GPIO server to be accessible over the network?" $DEFAULT 20 60 2
@ -1340,7 +1337,7 @@ do_advanced_menu() {
A8\ *) do_audio ;; A8\ *) do_audio ;;
A9\ *) do_gldriver ;; A9\ *) do_gldriver ;;
AA\ *) do_onewire ;; AA\ *) do_onewire ;;
AB\ *) do_gpiosec ;; AB\ *) do_rgpio ;;
A0\ *) do_update ;; A0\ *) do_update ;;
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;; *) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1 esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1
@ -1380,7 +1377,7 @@ if [ "$INTERACTIVE" = True ]; then
1\ *) do_expand_rootfs ;; 1\ *) do_expand_rootfs ;;
2\ *) do_change_pass ;; 2\ *) do_change_pass ;;
3\ *) do_boot_behaviour ;; 3\ *) do_boot_behaviour ;;
4\ *) do_wait_for_network ;; 4\ *) do_boot_wait ;;
5\ *) do_internationalisation_menu ;; 5\ *) do_internationalisation_menu ;;
6\ *) do_camera ;; 6\ *) do_camera ;;
7\ *) do_rastrack ;; 7\ *) do_rastrack ;;