-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathdisable-wps.sh
More file actions
71 lines (59 loc) · 1.83 KB
/
disable-wps.sh
File metadata and controls
71 lines (59 loc) · 1.83 KB
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
#!/bin/sh
# Made by Jack'lul <jacklul.github.io>
#
# Ensure that WPS is disabled on the router
#
# Based on:
# https://www.snbforums.com/threads/asus-rt-ac87u-stepped-into-the-382-branch-d.44227/#post-376642
#
#jas-update=disable-wps.sh
#shellcheck shell=ash
#shellcheck disable=SC2155
#shellcheck source=./common.sh
readonly common_script="$(dirname "$0")/common.sh"
if [ -f "$common_script" ]; then . "$common_script"; else { echo "$common_script not found" >&2; exit 1; } fi
CRON="0 0 * * *" # schedule as cron string
load_script_config
disable_wps() {
[ "$(nvram get wps_enable)" != "0" ] && nvram set wps_enable=0 && _changed=1
[ "$(nvram get wps_enable_x)" != "0" ] && nvram set wps_enable_x=0 && _changed=1
local _wps_mode_not_disabled="$(nvram show 2>/dev/null | grep "_wps_mode" | grep -v "=disabled" | cut -d '=' -f 1)"
local _variable _value _changed
IFS="$(printf '\n\b')"
for _variable in $_wps_mode_not_disabled; do
_value="$(nvram get "$_variable")"
if [ -n "$_value" ] && [ "$_value" != "disabled" ]; then
nvram set "$_variable=disabled"
_changed=1
fi
done
if [ -n "$_changed" ]; then
nvram commit
service restart_wireless
logecho "WPS has been disabled" alert
fi
}
case "$1" in
"run")
disable_wps
;;
"start")
[ -n "$CRON" ] && crontab_entry add "$CRON $script_path run"
if [ -z "$IS_INTERACTIVE" ] && [ "$(awk -F '.' '{print $1}' /proc/uptime)" -lt 300 ]; then
{ sleep 60 && disable_wps; } & # delay when freshly booted
else
disable_wps
fi
;;
"stop")
crontab_entry delete
;;
"restart")
sh "$script_path" stop
sh "$script_path" start
;;
*)
echo "Usage: $0 run|start|stop|restart"
exit 1
;;
esac