summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2018-10-18 14:10:00 -0400
committerJesse Luehrs <doy@tozt.net>2018-10-18 14:10:12 -0400
commit78a6a52b61b53eeaa6e13074897917b6329b468c (patch)
tree893e9ed2abf675c85c1f19cbb32744c25d2050b7
parented4dcb998d6a856b17c966fb9c93d14b688621db (diff)
downloadconf-78a6a52b61b53eeaa6e13074897917b6329b468c.tar.gz
conf-78a6a52b61b53eeaa6e13074897917b6329b468c.zip
improvements to my wifi script
-rwxr-xr-xbin/wifi10
1 files changed, 9 insertions, 1 deletions
diff --git a/bin/wifi b/bin/wifi
index ccd5b04..4253a30 100755
--- a/bin/wifi
+++ b/bin/wifi
@@ -1,4 +1,6 @@
#!/bin/sh
+set -eu
+set -o pipefail
DEV=wlp3s0
OPEN=open
@@ -12,7 +14,13 @@ if [ -z "$1" ]; then
else
case $1 in
open)
- if ! sudo netctl status $OPEN > /dev/null 2>&1; then
+ if [ -n "$2" ]; then
+ sudo sed -i "s/^ESSID=.*/ESSID='${2}'/" "/etc/netctl/${OPEN}"
+ fi
+
+ if sudo netctl status $OPEN > /dev/null 2>&1; then
+ sudo netctl restart $OPEN
+ else
sudo systemctl stop netctl-auto@$DEV
sudo netctl start $OPEN
fi