summaryrefslogtreecommitdiffstats
path: root/netset
blob: 747df16c66d40476437ee132d25aad6b21f95b43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#! /bin/bash

NETCTL=$(which netctl)
if [ -z "$NETCTL" ]
then
    echo "netctl not found"
    exit 1
fi
if [ $UID -ne 0 ]
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
N=0
dev=$(cat /etc/netctl/$profile | sed -n 's/Interface\=\(.*\)/\1/p')
ADDR=""
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 | sed -n '/inet /p')
done
echo
echo $ADDR