summaryrefslogtreecommitdiffstats
path: root/src/netcfg
blob: bea963ce28c218ce78805a2c45ddc36296ead2ef (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash

. /etc/rc.conf
. /usr/lib/network/network

NETCFG_VER=2.2.1

version()
{
    echo "netcfg v$NETCFG_VER"
}

usage()
{
    version
    echo "Usage:"
    echo "      Start specified profile:    netcfg profile " 
    echo "      Other functions:            netcfg argument profile"
    echo "Arguments:"
    echo "-a, all-down       Take all active profiles down"
    echo "-c, check-iface    Do not start profile if interface is already up"
    echo "-d, down           Take specified profile down"
    echo "-h, help           This help message"
    echo "-i, iface-down     Take down profile active on specified interface"
		echo "-r, reconnect      Disconnect and reconnect specified profile"
		echo "-u, up             Start specified profile"
    echo "-v, version        Output version information and exit"
    echo "    all-resume     Resume previously suspended profiles and reconnect them"
    echo "    all-suspend    Store a list of current running profiles and suspend them"
}

# TODO: Re-add ROOT check and rewrite with getopts from BashFAQ

case $1 in
    --version|-v|version) 
        version;;
    --help|-h|help) 
        usage;;
    -c|check-iface|-u|up)
        CHECK="YES"; 
        profile_up $2;;
   clean)
        rm /var/run/network/interfaces/* 2> /dev/null
        rm /var/run/network/profiles/* 2> /dev/null
				rm /var/run/network/suspend/* 2> /dev/null
				rm /var/run/network/last_profile 2> /dev/null
        killall wpa_supplicant 2> /dev/null
        killall dhcpcd 2> /dev/null
        ;;	
    -d|down) 
        profile_down $2;;
    -i|iface-down) 
        interface_down $2;;
    -a|all-down) 
        all_down;; 
		-r|reconnect)
				profile_down $2
				profile_up $2;;
    all-resume)
        all_resume;;
    all-suspend)
        all_suspend;;
    -*|--*) 
        usage;;
    *)  
        if [ -n "$1" ]; then
            profile_up $1
        else
            usage
        fi
        ;;  
esac
exit $?
# vim: set ts=2 noet: