/
netpro
executable file
·56 lines (50 loc) · 1.26 KB
/
netpro
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
#!/bin/bash
ROOT_UID=0
if [ "$UID" -ne "$ROOT_UID" ]
then
echo "You must be root to run this script."
exit 87
fi
saveprofile()
{
echo "Enter name for profile: "
read proname
echo
echo "Saved as /etc/network/net.$proname"
cp /etc/network/interfaces /etc/network/net.$proname
}
loadprofile()
{
ls /etc/network/net.*
echo "Enter net. profile to load without prefix: "
read proname
echo
cp /etc/network/interfaces /etc/network/interfaces.backup
echo "Current profile saved as /etc/network/interfaces.backup"
cp /etc/network/net.$proname /etc/network/interfaces
# The next lines are optional, they automatically restart the active interface.
# snip ------------------------------------
iface=$(cat /etc/network/interfaces |grep iface|cut -d" " -f2|sed 's/lo//g')
echo "$proname loaded! Restarting $iface"
ifdown $iface
ifup $iface
# ------------------------------------ snap
}
editprofile()
{
nano /etc/network/interfaces
}
echo "[s]ave current network profile as ..."
echo "[l]oad profile from list"
echo "[e]dit current interfaces file"
echo "[q]uit"
read -n1 -s sel
if [ $sel = 's' ]; then
saveprofile
elif [ $sel = 'l' ]; then
loadprofile
elif [ $sel = 'q' ]; then
exit 0
elif [ $sel = 'e' ]; then
editprofile
fi