]> git.ipfire.org Git - ipfire-2.x.git/blob - src/initscripts/system/network
Merge branch 'ipsec' into next
[ipfire-2.x.git] / src / initscripts / system / network
1 #!/bin/sh
2 ########################################################################
3 # Begin $rc_base/init.d/network
4 #
5 # Description : Network Control Script
6 #
7 # Authors : Michael Tremer - mitch@ipfire.org
8 #
9 # Version : 01.00
10 #
11 # Notes : Written for IPFire by its team
12 #
13 ########################################################################
14
15 . /etc/sysconfig/rc
16 . ${rc_functions}
17 eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
18
19 DO="${1}"
20 shift
21
22 if [ -n "${1}" ]; then
23 ALL=0
24 for i in green red blue orange; do
25 eval "${i}=0"
26 done
27 else
28 ALL=1
29 for i in green red blue orange; do
30 eval "${i}=1"
31 done
32 fi
33
34 while [ ! $# = 0 ]; do
35 for i in green red blue orange; do
36 if [ "${i}" == "${1}" ]; then
37 eval "${i}=1"
38 shift
39 fi
40 done
41 done
42
43 case "${DO}" in
44 start)
45 # Starting interfaces...
46 # GREEN
47 [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green start
48
49 # BLUE
50 [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \
51 /etc/rc.d/init.d/networking/blue start
52
53 # ORANGE
54 [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \
55 /etc/rc.d/init.d/networking/orange start
56
57 # RED
58 if [ "$red" == "1" ]; then
59 if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
60 # Remove possible leftover files
61 rm -f /var/ipfire/red/{active,device,dial-on-demand,dns1,dns2,local-ipaddress,remote-ipaddress,resolv.conf}
62 [ "$AUTOCONNECT" == "off" ] || /etc/rc.d/init.d/networking/red start
63 fi
64 fi
65
66 # Create IPsec interfaces
67 /usr/local/bin/ipsec-interfaces
68
69 /etc/rc.d/init.d/static-routes start
70 ;;
71
72 stop)
73 # Stopping interfaces...
74 # GREEN
75 [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green stop
76
77 # BLUE
78 [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \
79 /etc/rc.d/init.d/networking/blue stop
80
81 # ORANGE
82 [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \
83 /etc/rc.d/init.d/networking/orange stop
84
85 # RED
86 if [ "$red" == "1" ]; then
87 if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
88 /etc/rc.d/init.d/networking/red stop
89 fi
90 fi
91
92 exit 0
93 ;;
94
95 restart)
96 for i in green red blue orange; do
97 if [ "${!i}" == "1" ]; then
98 ARGS+=" ${i}"
99 fi
100 done
101 ${0} stop ${ARGS}
102 sleep 1
103 ${0} start ${ARGS}
104 ;;
105
106 *)
107 echo "Usage: ${0} {start|stop|restart} [device(s)]"
108 exit 1
109 ;;
110 esac
111
112 # End /etc/rc.d/init.d/network