]> git.ipfire.org Git - ipfire-2.x.git/blob - src/initscripts/system/network
Early spring clean: Remove trailing whitespaces, and correct licence headers
[ipfire-2.x.git] / src / initscripts / system / network
1 #!/bin/sh
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007-2022 IPFire Team <info@ipfire.org> #
6 # #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
11 # #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
16 # #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 # #
20 ###############################################################################
21
22 . /etc/sysconfig/rc
23 . ${rc_functions}
24 eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
25
26 DO="${1}"
27 shift
28
29 if [ -n "${1}" ]; then
30 ALL=0
31 for i in green red blue orange; do
32 eval "${i}=0"
33 done
34 else
35 ALL=1
36 for i in green red blue orange; do
37 eval "${i}=1"
38 done
39 fi
40
41 while [ ! $# = 0 ]; do
42 for i in green red blue orange; do
43 if [ "${i}" == "${1}" ]; then
44 eval "${i}=1"
45 shift
46 fi
47 done
48 done
49
50 case "${DO}" in
51 start)
52 # Starting interfaces...
53 # GREEN
54 [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green start
55
56 # BLUE
57 [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \
58 /etc/rc.d/init.d/networking/blue start
59
60 # ORANGE
61 [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \
62 /etc/rc.d/init.d/networking/orange start
63
64 # RED
65 if [ "$red" == "1" ]; then
66 if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
67 # Remove possible leftover files
68 rm -f /var/ipfire/red/{active,device,dial-on-demand,dns1,dns2,local-ipaddress,remote-ipaddress,resolv.conf}
69 [ "$AUTOCONNECT" == "off" ] || /etc/rc.d/init.d/networking/red start
70 fi
71 fi
72
73 # Create IPsec interfaces
74 /usr/local/bin/ipsec-interfaces
75
76 /etc/rc.d/init.d/static-routes start
77
78 boot_mesg "Mounting network file systems..."
79 mount -a -O _netdev
80 evaluate_retval
81 ;;
82
83 stop)
84 boot_mesg "Umounting network file systems..."
85 umount -a -O _netdev
86 evaluate_retval
87
88 # Stopping interfaces...
89 # GREEN
90 [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green stop
91
92 # BLUE
93 [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \
94 /etc/rc.d/init.d/networking/blue stop
95
96 # ORANGE
97 [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \
98 /etc/rc.d/init.d/networking/orange stop
99
100 # RED
101 if [ "$red" == "1" ]; then
102 if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
103 /etc/rc.d/init.d/networking/red stop
104 fi
105 fi
106
107 exit 0
108 ;;
109
110 restart)
111 for i in green red blue orange; do
112 if [ "${!i}" == "1" ]; then
113 ARGS+=" ${i}"
114 fi
115 done
116 ${0} stop ${ARGS}
117 sleep 1
118 ${0} start ${ARGS}
119 ;;
120
121 *)
122 echo "Usage: ${0} {start|stop|restart} [device(s)]"
123 exit 1
124 ;;
125 esac