From f1a012e8033de4cc49117488a147bd5461e8efa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 30 Mar 2018 18:05:42 +0200 Subject: improve netset --- netset | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/netset b/netset index b1627c2..f6742d9 100755 --- a/netset +++ b/netset @@ -11,10 +11,22 @@ then echo "must be run as root" exit 1 fi -$NETCTL stop-all -PROFILES=$($NETCTL list) +PROFILES=$($NETCTL list | sed 's/\*//') select profile in $PROFILES do [ -z "$profile" ] && exit 0 - echo "starting profile $profile" && $NETCTL start $profile; break + $NETCTL stop-all + echo "starting profile $profile" && sleep 1 && $NETCTL start $profile || exit 1 + break done +N=0 +dev=$(cat /etc/netctl/$profile | sed -n 's/Interface\=\(.*\)/\1/p') +ADDR=$(ip -c addr show dev $dev | grep inet) +while [ -z "$ADDR" ] +do + N=$((N + 1)) + [ $N -eq 10 ] && echo " failure" && exit 1 + echo -n "." && sleep 1 + ADDR=$(ip -c addr show dev $dev | grep inet) +done +echo $ADDR -- cgit v1.1-2-g2b99