Debian Codegraph @

etc/init.d/networking

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 ### BEGIN INIT INFO
3 # Provides: networking ifupdown
4 # Required-Start: mountkernfs $local_fs urandom
5 # Required-Stop: $local_fs
6 # Default-Start: S
7 # Default-Stop: 0 6
8 # Short-Description: Raise network interfaces.
9 # Description: Prepare /run/network directory, ifstate file and raise network interfaces, or take them down.
10 ### END INIT INFO
11
12 RUN_DIR="/run/networkscip-shell filesystem . . `/run/network`."
13 IFSTATE_LOCKFILE="${RUN_DIR}/ifstatelock"
14
15 STATE_DIR="/var/tmp/networkscip-shell filesystem . . `/var/tmp/network`."
16 IFSTATE_FILE="${STATE_DIR}/ifstatenew"
17
18 NAME=networking
19 SCRIPTNAME=/etc/init.d/$NAME
20
21 [scip-shell system . . `[`. -x /sbin/ifupscip-shell filesystem . . `/sbin/ifup`. ] || exit 0
22 [scip-shell system . . `[`. -x /sbin/ifdownscip-shell filesystem . . `/sbin/ifdown`. ] || exit 0
23
24 . /lib/lsb/init-functionsscip-shell source . . `/lib/lsb/init-functions`.
25
26 CONFIGURE_INTERFACES=yes
27
28 EXTRA_ARGS=
29
30 [scip-shell system . . `[`. -f /etc/default/networkingscip-shell filesystem . . `/etc/default/networking`. ] && . /etc/default/networkingscip-shell source . . `/etc/default/networking`.
31
32 [scip-shell system . . `[`. "$VERBOSE" = yes ] && EXTRA_ARGS=-v
33 [scip-shell system . . `[`. "$DEBUG" = yes ] && EXTRA_ARGS="$EXTRA_ARGS -d"
34 [scip-shell system . . `[`. "$SYSLOG" = yes ] && EXTRA_ARGS="$EXTRA_ARGS --syslog"
35
36 gen_examplesscip-shell shell shell-project 0.0.0 gen_examples().() {
37 # Generate sample interfaces file. The interfaces files are
38 # generated under /usr/share/doc/ifupdown2/examples/
39 #
40
41 # generate files only at boot
42 [scip-shell system . . `[`. -f ${IFSTATE_LOCKFILE} ] && return
43
44 python_ifupdown2_docdir="/usr/share/doc/ifupdown2scip-shell filesystem . . `/usr/share/doc/ifupdown2`."
45 swpfile=${python_ifupdown2_docdir}"/examples/swp_defaults"
46 bridgedefaultfile=${python_ifupdown2_docdir}"/examples/bridge_untagged_default"
47 interfaces_gen_script=${python_ifupdown2_docdir}"/examples/generate_interfaces.py"
48
49 [scip-shell system . . `[`. ! -e $interfaces_gen_script ] && return
50 ret=$($interfaces_gen_script -s 2>&1 >$swpfile)
51 ret=$($interfaces_gen_script -b 2>&1 >$bridgedefaultfile)
52 return
53 }
54
55 perf_optionsscip-shell shell shell-project 0.0.0 perf_options().() {
56 # At bootup lets set perfmode
57 [scip-shell system . . `[`. -f ${IFSTATE_LOCKFILE} ] && echoscip-shell system . . echo. -n "" && return
58
59 echoscip-shell system . . echo. -n "--perfmode"
60 }
61
62 process_exclusionsscip-shell shell shell-project 0.0.0 process_exclusions().() {
63 set -- $EXCLUDE_INTERFACES
64 exclusions=""
65 for d
66 do
67 exclusions="-X $d $exclusions"
68 done
69 echoscip-shell system . . echo. $exclusions
70 }
71
72 check_network_file_systemsscip-shell shell shell-project 0.0.0 check_network_file_systems().() {
73 [scip-shell system . . `[`. -e /proc/mountsscip-shell filesystem . . `/proc/mounts`. ] || return 0
74
75 if [scip-shell system . . `[`. -e /etc/iscsi/iscsi.initramfsscip-shell filesystem . . `/etc/iscsi/iscsi.initramfs`. ]; then
76 log_warning_msg "not deconfiguring network interfaces: iSCSI root is mounted."
77 exit 0
78 fi
79
80 while read DEV MTPT FSTYPE REST; do
81 case $DEV in
82 /dev/nbd*|/dev/nd[a-z]*|/dev/etherd/e*)
83 log_warning_msg "not deconfiguring network interfaces: network devices still mounted."
84 exit 0
85 ;;
86 esac
87 case $FSTYPE in
88 nfs|nfs4|smbfs|ncp|ncpfs|cifs|coda|ocfs2|gfs|pvfs|pvfs2|fuse.httpfs|fuse.curlftpfs)
89 log_warning_msg "not deconfiguring network interfaces: network file systems still mounted."
90 exit 0
91 ;;
92 esac
93 done < /proc/mountsscip-shell filesystem . . `/proc/mounts`.
94 }
95
96 check_network_swapscip-shell shell shell-project 0.0.0 check_network_swap().() {
97 [scip-shell system . . `[`. -e /proc/swapsscip-shell filesystem . . `/proc/swaps`. ] || return 0
98
99 while read DEV MTPT FSTYPE REST; do
100 case $DEV in
101 /dev/nbd*|/dev/nd[a-z]*|/dev/etherd/e*)
102 log_warning_msg "not deconfiguring network interfaces: network swap still mounted."
103 exit 0
104 ;;
105 esac
106 done < /proc/swapsscip-shell filesystem . . `/proc/swaps`.
107 }
108
109 ifup_hotplugscip-shell shell shell-project 0.0.0 ifup_hotplug(). () {
110 if [scip-shell system . . `[`. -d /sys/class/netscip-shell filesystem . . `/sys/class/net`. ]
111 then
112 ifaces=$(for iface in $(ifquery --list --allow=hotplug 2>/dev/nullscip-shell filesystem . . `/dev/null`.)
113 do
114 link=${iface##:*}
115 link=${link##.*}
116 if [scip-shell system . . `[`. -e "/sys/class/net/$link" ] && [scip-shell system . . `[`. "$(catscip-shell system . . cat. /sys/class/net/$link/operstate)" = up ]
117 then
118 echoscip-shell system . . echo. "$iface"
119 fi
120 done)
121 if [scip-shell system . . `[`. -n "$ifaces" ]
122 then
123 ifup $ifaces "$@" || truescip-shell system . . true.
124 fi
125 fi
126 }
127
128 ifupdown_initscip-shell shell shell-project 0.0.0 ifupdown_init().() {
129 # remove state file at boot
130 [scip-shell system . . `[`. ! -e ${IFSTATE_LOCKFILE} ] && rmscip-shell system . . rm. -f ${IFSTATE_FILE}
131 [scip-shell system . . `[`. ! -e /run/networkscip-shell filesystem . . `/run/network`. ] && mkdirscip-shell system . . mkdir. -p /run/networkscip-shell filesystem . . `/run/network`. &>/dev/nullscip-shell filesystem . . `/dev/null`.
132 [scip-shell system . . `[`. ! -e /etc/network/runscip-shell filesystem . . `/etc/network/run`. ] && \
133 ln -sf /run/networkscip-shell filesystem . . `/run/network`. /etc/network/runscip-shell filesystem . . `/etc/network/run`. &>/dev/nullscip-shell filesystem . . `/dev/null`.
134 }
135
136 case "$1" in
137 start)
138 gen_examplesscip-shell shell shell-project 0.0.0 gen_examples().
139 ifupdown_initscip-shell shell shell-project 0.0.0 ifupdown_init().
140 if [scip-shell system . . `[`. "$CONFIGURE_INTERFACES" = no ]
141 then
142 log_action_msg "Not configuring network interfaces, see /etc/default/networking"
143 exit 0
144 fi
145 set -f
146 exclusions=$(process_exclusionsscip-shell shell shell-project 0.0.0 process_exclusions().)
147 perfoptions=$(perf_optionsscip-shell shell shell-project 0.0.0 perf_options().)
148 log_action_begin_msg "Configuring network interfaces"
149 ifup -a $EXTRA_ARGS $exclusions $perfoptions
150 log_action_end_msg $?
151 ;;
152
153 stop)
154 if [scip-shell system . . `[`. "$SKIP_DOWN_AT_SYSRESET" = "yes" ]; then
155 shutdown_or_reboot=$(runlevel 2>/dev/nullscip-shell filesystem . . `/dev/null`. | \
156 /usr/bin/tr -s " " | \
157 /usr/bin/cut -d " " \
158 -f1- --output-delimiter=$'\n' | \
159 /bin/grep -e "0" -e "6")
160 if [scip-shell system . . `[`. -n "$shutdown_or_reboot" ]; then
161 log_action_begin_msg "Deconfiguring network interfaces..skip"
162 log_action_end_msg 0
163 exit 0
164 fi
165 fi
166 ifupdown_initscip-shell shell shell-project 0.0.0 ifupdown_init().
167 check_network_file_systemsscip-shell shell shell-project 0.0.0 check_network_file_systems().
168 check_network_swapscip-shell shell shell-project 0.0.0 check_network_swap().
169 exclusions=$(process_exclusionsscip-shell shell shell-project 0.0.0 process_exclusions().)
170
171 log_action_begin_msg "Deconfiguring network interfaces"
172 ifdown -a $EXTRA_ARGS $exclusions
173 log_action_end_msg $?
174 ;;
175
176 reload)
177
178 ifupdown_initscip-shell shell shell-project 0.0.0 ifupdown_init().
179 log_action_begin_msg "Reloading network interfaces configuration"
180
181 ifreload -a $EXTRA_ARGS
182 log_action_end_msg $?
183 ;;
184
185 reload-currently-up)
186
187 ifupdown_initscip-shell shell shell-project 0.0.0 ifupdown_init().
188 log_action_begin_msg "Reloading currently up network interfaces configuration"
189
190 ifreload --currently-up $EXTRA_ARGS
191 log_action_end_msg $?
192 ;;
193
194 force-reload)
195
196 ifupdown_initscip-shell shell shell-project 0.0.0 ifupdown_init().
197
198 log_action_begin_msg "Reloading network interfaces configuration"
199 ifreload -f -a $EXTRA_ARGS
200 log_action_end_msg $?
201 ;;
202
203 restart)
204 ifupdown_initscip-shell shell shell-project 0.0.0 ifupdown_init().
205
206 set -f
207 exclusions=$(process_exclusionsscip-shell shell shell-project 0.0.0 process_exclusions().)
208 log_action_begin_msg "Reconfiguring network interfaces"
209 ifdown -a $EXTRA_ARGS $exclusions || truescip-shell system . . true.
210 ifup -a $EXTRA_ARGS $exclusions
211 log_action_end_msg $?
212 ;;
213
214 *)
215 echoscip-shell system . . echo. "Usage: /etc/init.d/networking {start|stop|reload|restart|force-reload}"
216 exit 1
217 ;;
218 esac
219
220 exit 0
221
222 # vim: noet ts=8