-
-
Notifications
You must be signed in to change notification settings - Fork 266
/
Copy pathdisable-wifi-ap
executable file
·78 lines (64 loc) · 1.7 KB
/
disable-wifi-ap
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
#
# Disable TinyPilot WiFi access point.
# Exit on first failure.
set -e
# Echo commands before executing them, by default to stderr.
set -x
# Exit on unset variable.
set -u
if (( "${EUID}" != 0 )); then
>&2 echo 'This script requires root privileges.'
>&2 echo 'Please re-run with sudo:'
>&2 echo " sudo $0 $*"
>&2 exit 1
fi
print_help() {
cat <<EOF
Usage: ${0##*/} [--help]
Disable TinyPilot WiFi access point.
--help Display this help and exit.
Note: Running this script will clear any potentially existing custom static IP
configuration and also any potentially existing WiFi settings that might
have been set up previously.
EOF
}
# Parse command-line arguments.
while (( "$#" > 0 )); do
case "$1" in
--help)
print_help
exit
;;
*)
>&2 echo "Unknown agrument: $1"
>&2 print_help
exit 1
;;
esac
done
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
readonly SCRIPT_DIR
# shellcheck source=lib/markers.sh
. "${SCRIPT_DIR}/lib/markers.sh"
# Clear existing TinyPilot network configurations.
"${SCRIPT_DIR}/strip-marker-sections" /etc/dhcpcd.conf
# Restore previously backed up WPA configurations.
if [[ -e /etc/wpa_supplicant/wpa_supplicant.conf.bak ]]; then
mv \
/etc/wpa_supplicant/wpa_supplicant.conf.bak \
/etc/wpa_supplicant/wpa_supplicant.conf
fi
# Disable WPA.
if [[ -e /etc/wpa_supplicant/wlan_enabled ]]; then
rm --force /etc/wpa_supplicant/wlan_enabled
else
rfkill block wlan
fi
# Stop wireless access point.
systemctl stop hostapd dnsmasq
rm --force \
/etc/hostapd/hostapd.conf \
/etc/dnsmasq.conf
apt remove hostapd dnsmasq --yes
echo 'TinyPilot has disabled its WiFi access point.'