mirror of
https://github.com/brain-hackers/brain-config.git
synced 2024-12-22 20:20:06 +09:00
Tidied function to control remote GPIO access.
This commit is contained in:
parent
1ff5c921f6
commit
59649e8ba7
57
raspi-config
57
raspi-config
@ -904,42 +904,37 @@ 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]
|
||||||
ExecStart=
|
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
|
|
||||||
return 0
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user