summaryrefslogtreecommitdiffstats
path: root/netset
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2020-02-11 11:35:58 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2020-02-11 11:35:58 +0100
commit249fc3c9a06247e56d078538f20dd67c898126b4 (patch)
tree5d1c909a12677c5e8984b2540eeb95353bd4e2de /netset
parente8d6d89641bf6febebfc2e18217adb0191f11f07 (diff)
downloadbin-249fc3c9a06247e56d078538f20dd67c898126b4.zip
bin-249fc3c9a06247e56d078538f20dd67c898126b4.tar.gz
netset : support network profile as first argument
Diffstat (limited to 'netset')
-rwxr-xr-xnetset25
1 files changed, 17 insertions, 8 deletions
diff --git a/netset b/netset
index 83e19b9..cf28795 100755
--- a/netset
+++ b/netset
@@ -11,14 +11,23 @@ then
echo "must be run as root"
exit 1
fi
-PROFILES=$($NETCTL list | sed 's/\*//' | sort)
-select profile in $PROFILES
-do
- [ -z "$profile" ] && exit 0
- $NETCTL stop-all
- echo "starting profile $profile" && sleep 1 && $NETCTL start $profile || exit 1
- break
-done
+if [ $# -gt 0 ]
+then
+ profile=$1
+else
+ PROFILES=$($NETCTL list | sed 's/\*//' | sort)
+ select profile in $PROFILES
+ do
+ [ -z "$profile" ] && exit 0
+ break
+ done
+fi
+if [ ! -r /etc/netctl/$profile ]
+then
+ echo "unknown network profile : $profile" && exit 1
+fi
+$NETCTL stop-all
+echo "starting profile $profile" && sleep 1 && $NETCTL start $profile || exit 1
N=0
dev=$(cat /etc/netctl/$profile | sed -n 's/Interface\=\(.*\)/\1/p')
ADDR=""