mirror of
https://github.com/brain-hackers/brain-config.git
synced 2024-12-22 12:10:07 +09:00
Tidied function to control remote GPIO access.
This commit is contained in:
parent
1ff5c921f6
commit
59649e8ba7
43
raspi-config
43
raspi-config
@ -904,23 +904,20 @@ do_gpiosec() {
|
||||
whiptail --msgbox "This option can only be selected when using systemd" 20 60 2
|
||||
return 1
|
||||
fi
|
||||
if [ "$INTERACTIVE" = True ]; then
|
||||
RET=$(whiptail --menu "Choose GPIO Access Mode" 20 70 10 \
|
||||
"Public" "GPIO server can be accessed remotely" \
|
||||
"Private" "GPIO server can only be accessed locally" \
|
||||
3>&1 1>&2 2>&3)
|
||||
else
|
||||
get_init_sys
|
||||
RET=$1
|
||||
true
|
||||
|
||||
DEFAULT=--defaultno
|
||||
CURRENT=0
|
||||
if [ $(get_rgpio) -eq 0 ]; then
|
||||
DEFAULT=
|
||||
CURRENT=1
|
||||
fi
|
||||
if [ $? -eq 0 ]; then
|
||||
case "$RET" in
|
||||
Private)
|
||||
rm -f /etc/systemd/system/pigpiod.service.d/public.conf
|
||||
STATUS=disabled
|
||||
;;
|
||||
Public)
|
||||
if [ "$INTERACTIVE" = True ]; then
|
||||
whiptail --yesno "Would you like the GPIO server to be accessible over the network?" $DEFAULT 20 60 2
|
||||
RET=$?
|
||||
else
|
||||
RET=$1
|
||||
fi
|
||||
if [ $RET -eq 0 ]; then
|
||||
mkdir -p /etc/systemd/system/pigpiod.service.d/
|
||||
cat > /etc/systemd/system/pigpiod.service.d/public.conf << EOF
|
||||
[Service]
|
||||
@ -928,19 +925,17 @@ ExecStart=
|
||||
ExecStart=/usr/bin/pigpiod
|
||||
EOF
|
||||
STATUS=enabled
|
||||
;;
|
||||
*)
|
||||
whiptail --msgbox "Programmer error, unrecognised option" 20 60 2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
elif [ $RET -eq 1 ]; then
|
||||
rm -f /etc/systemd/system/pigpiod.service.d/public.conf
|
||||
STATUS=disabled
|
||||
else
|
||||
return $RET
|
||||
fi
|
||||
systemctl daemon-reload
|
||||
systemctl restart pigpiod
|
||||
if [ "$INTERACTIVE" = True ]; then
|
||||
whiptail --msgbox "Remote access to the GPIO server is $STATUS" 20 60 1
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
do_rastrack() {
|
||||
|
Loading…
Reference in New Issue
Block a user