diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..065f7d4 --- /dev/null +++ b/install.sh @@ -0,0 +1,8 @@ +#!/bin/bash +echo "Installing wifi reset service to /opt/wifi-reset." +mkdir -p /opt/wifi-reset +cp -f wifi-reset.sh /opt/wifi-reset/wifi-reset.sh +echo "Installing systemd service to run at boot." +cp -f wifi-reset.service /lib/systemd/system/wifi-reset.service +echo "Enabling systemd service." +systemctl enable wifi-reset.service > /dev/null diff --git a/wifi-reset.service b/wifi-reset.service new file mode 100644 index 0000000..6f5c0e3 --- /dev/null +++ b/wifi-reset.service @@ -0,0 +1,10 @@ +[Unit] +Description=Wireless Network Reset + +[Service] +Type=oneshot +RemainAfterExit=true +ExecStart=/bin/bash /opt/wifi-reset/wifi-reset.sh + +[Install] +WantedBy=multi-user.target diff --git a/wifi-reset.sh b/wifi-reset.sh new file mode 100755 index 0000000..bdf1ca4 --- /dev/null +++ b/wifi-reset.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# Bring all wifi interfaces down. +# Identify wifi interfaces as rows from standard output of iwconfig (NOT standard +# error, those are non-wifi interfaces) which start without whitespace. +iwconfig 2> /dev/null | grep -o '^[[:alnum:]]\+' | while read x; do ifdown $x; done +# Bring all wifi interfaces up. +iwconfig 2> /dev/null | grep -o '^[[:alnum:]]\+' | while read x; do ifup $x; done