aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorubuntuperonista <30541016+ubuntuperonista@users.noreply.github.com>2023-03-02 17:50:33 -0300
committerGitHub <noreply@github.com>2023-03-02 17:50:33 -0300
commitc9975c15edb7808d5bea4969c8cb63abcdc78ed7 (patch)
treea745a290d7e5a07dba5ef437232acc4e654898ec
parentc19e905822cb4b272ee79f358cdf42e69cb1f313 (diff)
downloadopenwrt_scripts-c9975c15edb7808d5bea4969c8cb63abcdc78ed7.tar.gz
Create wifionoff.sh
Toggles wifi with a button
-rw-r--r--wifionoff.sh34
1 files changed, 34 insertions, 0 deletions
diff --git a/wifionoff.sh b/wifionoff.sh
new file mode 100644
index 0000000..0493b95
--- /dev/null
+++ b/wifionoff.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+# Crea un archivo con el registro de estado del Wifi (on u off)
+# Si el wifi está on lo apaga, si está off lo enciende.
+STATEFILE="/tmp/wifionoff.state"
+
+if [ $# -eq 1 ]; then
+ case $1 in
+ "up"|"on")
+ STATE=off
+ ;;
+ "down"|"off")
+ STATE=on
+ ;;
+ esac
+else
+ if [ ! -e ${STATEFILE} ]; then
+ STATE=on
+ else
+ . ${STATEFILE}
+ fi
+fi
+if [ -z ${STATE} ]; then
+ STATE=on
+fi
+
+if [ ${STATE} == "on" ]; then
+ /sbin/wifi down
+ STATE=off
+else
+ /sbin/wifi up
+ STATE=on
+fi
+
+echo "STATE=${STATE}" > ${STATEFILE}
Un proyecto texto-plano.xyz