diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2020-02-11 11:35:58 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2020-02-11 11:35:58 +0100 |
commit | 249fc3c9a06247e56d078538f20dd67c898126b4 (patch) | |
tree | 5d1c909a12677c5e8984b2540eeb95353bd4e2de | |
parent | e8d6d89641bf6febebfc2e18217adb0191f11f07 (diff) | |
download | bin-249fc3c9a06247e56d078538f20dd67c898126b4.zip bin-249fc3c9a06247e56d078538f20dd67c898126b4.tar.gz |
netset : support network profile as first argument
-rwxr-xr-x | netset | 25 |
1 files changed, 17 insertions, 8 deletions
@@ -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="" |