Added more success / fail feedback to settings.

This commit is contained in:
spl 2016-05-24 13:01:17 +01:00
parent a8a933ef64
commit 934fefebf2

View File

@ -485,15 +485,14 @@ get_ssh() {
} }
do_ssh() { do_ssh() {
DEFAULT=--defaultno
if [ $(get_ssh) -eq 0 ]; then
DEFAULT=
fi
if [ -e /var/log/regen_ssh_keys.log ] && ! grep -q "^finished" /var/log/regen_ssh_keys.log; then if [ -e /var/log/regen_ssh_keys.log ] && ! grep -q "^finished" /var/log/regen_ssh_keys.log; then
whiptail --msgbox "Initial ssh key generation still running. Please wait and try again." 20 60 2 whiptail --msgbox "Initial ssh key generation still running. Please wait and try again." 20 60 2
return 1 return 1
fi fi
DEFAULT=--defaultno
if [ $(get_ssh) -eq 0 ]; then
DEFAULT=
fi
if [ "$INTERACTIVE" = True ]; then if [ "$INTERACTIVE" = True ]; then
whiptail --yesno "Would you like the SSH server to be enabled?" $DEFAULT 20 60 2 whiptail --yesno "Would you like the SSH server to be enabled?" $DEFAULT 20 60 2
RET=$? RET=$?
@ -503,18 +502,17 @@ do_ssh() {
if [ $RET -eq 0 ]; then if [ $RET -eq 0 ]; then
update-rc.d ssh enable && update-rc.d ssh enable &&
invoke-rc.d ssh start && invoke-rc.d ssh start &&
if [ "$INTERACTIVE" = True ]; then STATUS=enabled
whiptail --msgbox "The SSH server is enabled" 20 60 1
fi
elif [ $RET -eq 1 ]; then elif [ $RET -eq 1 ]; then
update-rc.d ssh disable && update-rc.d ssh disable &&
invoke-rc.d ssh stop && invoke-rc.d ssh stop &&
if [ "$INTERACTIVE" = True ]; then STATUS=disabled
whiptail --msgbox "The SSH server is disabled" 20 60 1
fi
else else
return $RET return $RET
fi fi
if [ "$INTERACTIVE" = True ]; then
whiptail --msgbox "The SSH server is $STATUS" 20 60 1
fi
} }
get_spi() { get_spi() {
@ -530,7 +528,6 @@ do_spi() {
if [ $(get_spi) -eq 0 ]; then if [ $(get_spi) -eq 0 ]; then
DEFAULT= DEFAULT=
fi fi
if [ "$INTERACTIVE" = True ]; then if [ "$INTERACTIVE" = True ]; then
whiptail --yesno "Would you like the SPI interface to be enabled?" $DEFAULT 20 60 2 whiptail --yesno "Would you like the SPI interface to be enabled?" $DEFAULT 20 60 2
RET=$? RET=$?
@ -544,8 +541,9 @@ do_spi() {
SETTING=off SETTING=off
STATUS=disabled STATUS=disabled
else else
return 0 return $RET
fi fi
set_config_var dtparam=spi $SETTING $CONFIG && set_config_var dtparam=spi $SETTING $CONFIG &&
if [ "$INTERACTIVE" = True ]; then if [ "$INTERACTIVE" = True ]; then
whiptail --msgbox "The SPI interface is $STATUS" 20 60 1 whiptail --msgbox "The SPI interface is $STATUS" 20 60 1
@ -572,7 +570,6 @@ do_i2c() {
if [ $(get_i2c) -eq 0 ]; then if [ $(get_i2c) -eq 0 ]; then
DEFAULT= DEFAULT=
fi fi
if [ "$INTERACTIVE" = True ]; then if [ "$INTERACTIVE" = True ]; then
whiptail --yesno "Would you like the ARM I2C interface to be enabled?" $DEFAULT 20 60 2 whiptail --yesno "Would you like the ARM I2C interface to be enabled?" $DEFAULT 20 60 2
RET=$? RET=$?
@ -586,7 +583,7 @@ do_i2c() {
SETTING=off SETTING=off
STATUS=disabled STATUS=disabled
else else
return 0 return $RET
fi fi
set_config_var dtparam=i2c_arm $SETTING $CONFIG && set_config_var dtparam=i2c_arm $SETTING $CONFIG &&
@ -631,7 +628,6 @@ do_serial() {
DEFAULT= DEFAULT=
CURRENT=1 CURRENT=1
fi fi
if [ "$INTERACTIVE" = True ]; then if [ "$INTERACTIVE" = True ]; then
whiptail --yesno "Would you like a login shell to be accessible over serial?" $DEFAULT 20 60 2 whiptail --yesno "Would you like a login shell to be accessible over serial?" $DEFAULT 20 60 2
RET=$? RET=$?
@ -642,17 +638,7 @@ do_serial() {
if [ $RET -eq $CURRENT ]; then if [ $RET -eq $CURRENT ]; then
ASK_TO_REBOOT=1 ASK_TO_REBOOT=1
fi fi
if [ $RET -eq 1 ]; then if [ $RET -eq 0 ]; then
if [ $SYSTEMD -eq 0 ]; then
sed -i /etc/inittab -e "s|^.*:.*:respawn:.*ttyAMA0|#&|"
fi
sed -i /boot/cmdline.txt -e "s/console=ttyAMA0,[0-9]\+ //"
sed -i /boot/cmdline.txt -e "s/console=serial0,[0-9]\+ //"
set_config_var enable_uart 0 $CONFIG
if [ "$INTERACTIVE" = True ]; then
whiptail --msgbox "The serial interface is disabled" 20 60 1
fi
elif [ $RET -eq 0 ]; then
if [ $SYSTEMD -eq 0 ]; then if [ $SYSTEMD -eq 0 ]; then
sed -i /etc/inittab -e "s|^#\(.*:.*:respawn:.*ttyAMA0\)|\1|" sed -i /etc/inittab -e "s|^#\(.*:.*:respawn:.*ttyAMA0\)|\1|"
if ! grep -q "^T.*:.*:respawn:.*ttyAMA0" /etc/inittab; then if ! grep -q "^T.*:.*:respawn:.*ttyAMA0" /etc/inittab; then
@ -671,12 +657,21 @@ do_serial() {
fi fi
fi fi
set_config_var enable_uart 1 $CONFIG set_config_var enable_uart 1 $CONFIG
if [ "$INTERACTIVE" = True ]; then STATUS=enabled
whiptail --msgbox "The serial interface is enabled" 20 60 1 elif [ $RET -eq 1 ]; then
if [ $SYSTEMD -eq 0 ]; then
sed -i /etc/inittab -e "s|^.*:.*:respawn:.*ttyAMA0|#&|"
fi fi
sed -i /boot/cmdline.txt -e "s/console=ttyAMA0,[0-9]\+ //"
sed -i /boot/cmdline.txt -e "s/console=serial0,[0-9]\+ //"
set_config_var enable_uart 0 $CONFIG
STATUS=disabled
else else
return $RET return $RET
fi fi
if [ "$INTERACTIVE" = True ]; then
whiptail --msgbox "The serial interface is $STATUS" 20 60 1
fi
} }
disable_raspi_config_at_boot() { disable_raspi_config_at_boot() {
@ -881,6 +876,9 @@ do_gpiosec() {
case "$RET" in case "$RET" in
Private) Private)
rm -f /etc/systemd/system/pigpiod.service.d/public.conf rm -f /etc/systemd/system/pigpiod.service.d/public.conf
if [ "$INTERACTIVE" = True ]; then
whiptail --msgbox "Remote access to the GPIO server is disabled" 20 60 1
fi
;; ;;
Public) Public)
mkdir -p /etc/systemd/system/pigpiod.service.d/ mkdir -p /etc/systemd/system/pigpiod.service.d/
@ -889,6 +887,9 @@ do_gpiosec() {
ExecStart= ExecStart=
ExecStart=/usr/bin/pigpiod ExecStart=/usr/bin/pigpiod
EOF EOF
if [ "$INTERACTIVE" = True ]; then
whiptail --msgbox "Remote access to the GPIO server is enabled" 20 60 1
fi
;; ;;
*) *)
whiptail --msgbox "Programmer error, unrecognised option" 20 60 2 whiptail --msgbox "Programmer error, unrecognised option" 20 60 2
@ -939,6 +940,8 @@ do_camera() {
whiptail --msgbox "Your firmware appears to be out of date (no start_x.elf). Please update" 20 60 2 whiptail --msgbox "Your firmware appears to be out of date (no start_x.elf). Please update" 20 60 2
return 1 return 1
fi fi
sed $CONFIG -i -e "s/^startx/#startx/"
sed $CONFIG -i -e "s/^fixup_file/#fixup_file/"
DEFAULT=--defaultno DEFAULT=--defaultno
CURRENT=0 CURRENT=0
@ -946,9 +949,6 @@ do_camera() {
DEFAULT= DEFAULT=
CURRENT=1 CURRENT=1
fi fi
sed $CONFIG -i -e "s/^startx/#startx/"
sed $CONFIG -i -e "s/^fixup_file/#fixup_file/"
if [ "$INTERACTIVE" = True ]; then if [ "$INTERACTIVE" = True ]; then
whiptail --yesno "Would you like the camera interface to be enabled?" $DEFAULT 20 60 2 whiptail --yesno "Would you like the camera interface to be enabled?" $DEFAULT 20 60 2
RET=$? RET=$?
@ -958,23 +958,22 @@ do_camera() {
if [ $RET -eq $CURRENT ]; then if [ $RET -eq $CURRENT ]; then
ASK_TO_REBOOT=1 ASK_TO_REBOOT=1
fi fi
if [ $RET -eq 1 ]; then if [ $RET -eq 0 ]; then
set_config_var start_x 0 $CONFIG
sed $CONFIG -i -e "s/^start_file/#start_file/"
if [ "$INTERACTIVE" = True ]; then
whiptail --msgbox "The camera interface is disabled" 20 60 1
fi
elif [ $RET -eq 0 ]; then
set_config_var start_x 1 $CONFIG set_config_var start_x 1 $CONFIG
CUR_GPU_MEM=$(get_config_var gpu_mem $CONFIG) CUR_GPU_MEM=$(get_config_var gpu_mem $CONFIG)
if [ -z "$CUR_GPU_MEM" ] || [ "$CUR_GPU_MEM" -lt 128 ]; then if [ -z "$CUR_GPU_MEM" ] || [ "$CUR_GPU_MEM" -lt 128 ]; then
set_config_var gpu_mem 128 $CONFIG set_config_var gpu_mem 128 $CONFIG
fi fi
if [ "$INTERACTIVE" = True ]; then STATUS=enabled
whiptail --msgbox "The camera interface is enabled" 20 60 1 elif [ $RET -eq 1 ]; then
fi set_config_var start_x 0 $CONFIG
sed $CONFIG -i -e "s/^start_file/#start_file/"
STATUS=disabled
else else
return 1 return $RET
fi
if [ "$INTERACTIVE" = True ]; then
whiptail --msgbox "The camera interface is $STATUS" 20 60 1
fi fi
} }
@ -993,7 +992,6 @@ do_onewire() {
DEFAULT= DEFAULT=
CURRENT=1 CURRENT=1
fi fi
if [ "$INTERACTIVE" = True ]; then if [ "$INTERACTIVE" = True ]; then
whiptail --yesno "Would you like the one-wire interface to be enabled?" $DEFAULT 20 60 2 whiptail --yesno "Would you like the one-wire interface to be enabled?" $DEFAULT 20 60 2
RET=$? RET=$?
@ -1008,16 +1006,15 @@ do_onewire() {
if ! grep -q -E "^dtoverlay=w1-gpio" $CONFIG; then if ! grep -q -E "^dtoverlay=w1-gpio" $CONFIG; then
printf "dtoverlay=w1-gpio\n" >> $CONFIG printf "dtoverlay=w1-gpio\n" >> $CONFIG
fi fi
if [ "$INTERACTIVE" = True ]; then STATUS=enabled
whiptail --msgbox "The one-wire interface is enabled" 20 60 1
fi
elif [ $RET -eq 1 ]; then elif [ $RET -eq 1 ]; then
sed $CONFIG -i -e "s/^dtoverlay=w1-gpio/#dtoverlay=w1-gpio/" sed $CONFIG -i -e "s/^dtoverlay=w1-gpio/#dtoverlay=w1-gpio/"
if [ "$INTERACTIVE" = True ]; then STATUS=disabled
whiptail --msgbox "The one-wire interface is disabled" 20 60 1
fi
else else
return 1 return $RET
fi
if [ "$INTERACTIVE" = True ]; then
whiptail --msgbox "The one-wire interface is $STATUS" 20 60 1
fi fi
} }