-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathdisable-diag.sh
48 lines (42 loc) · 1.28 KB
/
disable-diag.sh
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
#!/bin/sh
# Made by Jack'lul <jacklul.github.io>
#
# Disable diagnostics (?)
#
# Prevents conn_diag from starting amas_portstatus
#
#jacklul-asuswrt-scripts-update
#shellcheck disable=SC2155,SC2009
readonly SCRIPT_PATH="$(readlink -f "$0")"
readonly SCRIPT_NAME="$(basename "$SCRIPT_PATH" .sh)"
readonly SCRIPT_DIR="$(dirname "$SCRIPT_PATH")"
case "$1" in
"run")
if [ "$(nvram get enable_diag)" != "0" ]; then
[ ! -f "/tmp/conndiag_default" ] && nvram get enable_diag > "/tmp/conndiag_default"
nvram set enable_diag=0
killall conn_diag amas_portstatus
fi
;;
"start")
if [ -x "$SCRIPT_DIR/cron-queue.sh" ]; then
sh "$SCRIPT_DIR/cron-queue.sh" add "$SCRIPT_NAME" "$SCRIPT_PATH run"
else
cru a "$SCRIPT_NAME" "*/1 * * * * $SCRIPT_PATH run"
fi
sh "$SCRIPT_PATH" run
;;
"stop")
[ -x "$SCRIPT_DIR/cron-queue.sh" ] && sh "$SCRIPT_DIR/cron-queue.sh" remove "$SCRIPT_NAME"
cru d "$SCRIPT_NAME"
[ -f "/tmp/conndiag_default" ] && nvram set enable_diag="$(cat "/tmp/conndiag_default")"
;;
"restart")
sh "$SCRIPT_PATH" stop
sh "$SCRIPT_PATH" start
;;
*)
echo "Usage: $0 run|start|stop|restart"
exit 1
;;
esac