Tidied function to control remote GPIO access.

This commit is contained in:
spl 2016-05-25 13:21:58 +01:00
parent 1ff5c921f6
commit 59649e8ba7

View File

@ -904,23 +904,20 @@ do_gpiosec() {
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 GPIO Access Mode" 20 70 10 \ DEFAULT=--defaultno
"Public" "GPIO server can be accessed remotely" \ CURRENT=0
"Private" "GPIO server can only be accessed locally" \ if [ $(get_rgpio) -eq 0 ]; then
3>&1 1>&2 2>&3) DEFAULT=
else CURRENT=1
get_init_sys
RET=$1
true
fi fi
if [ $? -eq 0 ]; then if [ "$INTERACTIVE" = True ]; then
case "$RET" in whiptail --yesno "Would you like the GPIO server to be accessible over the network?" $DEFAULT 20 60 2
Private) RET=$?
rm -f /etc/systemd/system/pigpiod.service.d/public.conf else
STATUS=disabled RET=$1
;; fi
Public) if [ $RET -eq 0 ]; then
mkdir -p /etc/systemd/system/pigpiod.service.d/ mkdir -p /etc/systemd/system/pigpiod.service.d/
cat > /etc/systemd/system/pigpiod.service.d/public.conf << EOF cat > /etc/systemd/system/pigpiod.service.d/public.conf << EOF
[Service] [Service]
@ -928,19 +925,17 @@ ExecStart=
ExecStart=/usr/bin/pigpiod ExecStart=/usr/bin/pigpiod
EOF EOF
STATUS=enabled STATUS=enabled
;; elif [ $RET -eq 1 ]; then
*) rm -f /etc/systemd/system/pigpiod.service.d/public.conf
whiptail --msgbox "Programmer error, unrecognised option" 20 60 2 STATUS=disabled
return 1 else
;; return $RET
esac fi
systemctl daemon-reload systemctl daemon-reload
systemctl restart pigpiod systemctl restart pigpiod
if [ "$INTERACTIVE" = True ]; then if [ "$INTERACTIVE" = True ]; then
whiptail --msgbox "Remote access to the GPIO server is $STATUS" 20 60 1 whiptail --msgbox "Remote access to the GPIO server is $STATUS" 20 60 1
fi fi
return 0
fi
} }
do_rastrack() { do_rastrack() {