3 # This replaces the old init.d script, and is run from the networking.service
4 # Only has start, stop, reload, because that's all systemd has.
5 # restart is implemented in systemd by stop then start.
9 IFSTATE_LOCKFILE
="${RUN_DIR}/ifstatelock"
11 STATE_DIR
="/var/tmp/network"
12 IFSTATE_FILE
="${STATE_DIR}/ifstatenew"
16 [ -x /sbin
/ifup
] ||
exit 0
17 [ -x /sbin
/ifdown
] ||
exit 0
19 CONFIGURE_INTERFACES
=yes
23 [ -f /etc
/default
/networking
] && .
/etc
/default
/networking
25 [ "$VERBOSE" = yes ] && EXTRA_ARGS
=-v
26 [ "$DEBUG" = yes ] && EXTRA_ARGS
="$EXTRA_ARGS -d"
27 [ "$SYSLOG" = yes ] && EXTRA_ARGS
="$EXTRA_ARGS --syslog"
30 # At bootup lets set perfmode
31 [ -f ${IFSTATE_LOCKFILE} ] && echo -n "" && return
36 process_exclusions
() {
37 set -- $EXCLUDE_INTERFACES
41 exclusions
="-X $d $exclusions"
46 check_network_file_systems
() {
47 [ -e /proc
/mounts
] ||
return 0
49 if [ -e /etc
/iscsi
/iscsi.initramfs
]; then
50 echo ${NAME}':' "not deconfiguring network interfaces: iSCSI root is mounted."
54 while read DEV MTPT FSTYPE REST
; do
56 /dev
/nbd
*|
/dev
/nd
[a-z
]*|
/dev
/etherd
/e
*)
57 echo ${NAME}':' "not deconfiguring network interfaces: network devices still mounted."
62 nfs|nfs4|smbfs|ncp|ncpfs|cifs|coda|ocfs2|gfs|pvfs|pvfs2|fuse.httpfs|fuse.curlftpfs
)
63 echo ${NAME}':' "not deconfiguring network interfaces: network file systems still mounted."
70 check_network_swap
() {
71 [ -e /proc
/swaps
] ||
return 0
73 while read DEV MTPT FSTYPE REST
; do
75 /dev
/nbd
*|
/dev
/nd
[a-z
]*|
/dev
/etherd
/e
*)
76 echo ${NAME}':' "not deconfiguring network interfaces: network swap still mounted."
84 if [ -d /sys
/class
/net
]
86 ifaces
=$
(for iface
in $
(ifquery
--list --allow=hotplug
2>/dev
/null
)
90 if [ -e "/sys/class/net/$link" ]
97 ifup
$ifaces "$@" || true
103 ifaces
=$
(ifquery
--list --allow=mgmt
2>/dev
/null
)
104 if [ -n "$ifaces" ]; then
105 echo "bringing up mgmt class interfaces"
111 # remove state file at boot
112 [ ! -e ${IFSTATE_LOCKFILE} ] && rm -f ${IFSTATE_FILE}
114 [ ! -e /run
/network
] && mkdir
-p /run
/network
&>/dev
/null
115 [ ! -e /etc
/network
/run
] && \
116 ln -sf /run
/network
/etc
/network
/run
&>/dev
/null
122 if [ "$CONFIGURE_INTERFACES" = no
]
124 echo ${NAME}':' "Not configuring network interfaces, see /etc/default/networking"
128 exclusions
=$
(process_exclusions
)
129 perfoptions
=$
(perf_options
)
130 echo ${NAME}':' "Configuring network interfaces"
132 ifup
-a $EXTRA_ARGS $exclusions $perfoptions
133 ifup_hotplug
$HOTPLUG_ARGS $EXTRA_ARGS $exclusions
136 if [ "$SKIP_DOWN_AT_SYSRESET" = "yes" ]; then
138 systemctl list-jobs |
egrep -q '(shutdown|reboot|halt|poweroff)\.target'
139 [ $?
-eq 0 ] && SYSRESET
=1
140 if [ $SYSRESET -eq 1 ]; then
141 echo ${NAME}':' "Skipping deconfiguring network interfaces"
146 check_network_file_systems
148 exclusions
=$
(process_exclusions
)
150 echo ${NAME}':' "Deconfiguring network interfaces"
151 ifdown
-a $EXTRA_ARGS $exclusions
157 exclusions
=$
(process_exclusions
)
159 echo ${NAME}':' "Reloading network interfaces configuration"
160 ifreload
-a $EXTRA_ARGS $exclusions
164 echo ${NAME}':' "Usage: $0 {start|stop|reload}"