mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
Ticket: none Reviewed By: trivial Testing Done: installed, Alex tried for image creations. apparently with some of our packages like mstpd still using init.d for a while longer, just having the init.d/networking file causes the original complaints about loops between services. So I'm purging it completely. Also clean up the comments a bit in start-networking
145 lines
3.1 KiB
Bash
Executable File
145 lines
3.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# This replaces the old init.d script, and is run from the networking.service
|
|
# Only has start, stop, reload, because that's all systemd has.
|
|
# restart is implemented in systemd by stop then start.
|
|
|
|
PATH="/sbin:/bin"
|
|
RUN_DIR="/run/network"
|
|
IFSTATE="$RUN_DIR/ifstate"
|
|
|
|
NAME=networking
|
|
|
|
[ -x /sbin/ifup ] || exit 0
|
|
[ -x /sbin/ifdown ] || exit 0
|
|
|
|
CONFIGURE_INTERFACES=yes
|
|
|
|
EXTRA_ARGS=
|
|
|
|
[ -f /etc/default/networking ] && . /etc/default/networking
|
|
|
|
[ "$VERBOSE" = yes ] && EXTRA_ARGS=-v
|
|
[ "$DEBUG" = yes ] && EXTRA_ARGS="$EXTRA_ARGS -d"
|
|
[ "$SYSLOG" = yes ] && EXTRA_ARGS="$EXTRA_ARGS --syslog"
|
|
|
|
perf_options() {
|
|
# At bootup lets set perfmode
|
|
[ -f /var/tmp/network/ifstatenew ] && echo -n "" && return
|
|
|
|
echo -n "--perfmode"
|
|
}
|
|
|
|
process_exclusions() {
|
|
set -- $EXCLUDE_INTERFACES
|
|
exclusions=""
|
|
for d
|
|
do
|
|
exclusions="-X $d $exclusions"
|
|
done
|
|
echo $exclusions
|
|
}
|
|
|
|
check_network_file_systems() {
|
|
[ -e /proc/mounts ] || return 0
|
|
|
|
if [ -e /etc/iscsi/iscsi.initramfs ]; then
|
|
echo ${NAME}':' "not deconfiguring network interfaces: iSCSI root is mounted."
|
|
exit 0
|
|
fi
|
|
|
|
while read DEV MTPT FSTYPE REST; do
|
|
case $DEV in
|
|
/dev/nbd*|/dev/nd[a-z]*|/dev/etherd/e*)
|
|
echo ${NAME}':' "not deconfiguring network interfaces: network devices still mounted."
|
|
exit 0
|
|
;;
|
|
esac
|
|
case $FSTYPE in
|
|
nfs|nfs4|smbfs|ncp|ncpfs|cifs|coda|ocfs2|gfs|pvfs|pvfs2|fuse.httpfs|fuse.curlftpfs)
|
|
echo ${NAME}':' "not deconfiguring network interfaces: network file systems still mounted."
|
|
exit 0
|
|
;;
|
|
esac
|
|
done < /proc/mounts
|
|
}
|
|
|
|
check_network_swap() {
|
|
[ -e /proc/swaps ] || return 0
|
|
|
|
while read DEV MTPT FSTYPE REST; do
|
|
case $DEV in
|
|
/dev/nbd*|/dev/nd[a-z]*|/dev/etherd/e*)
|
|
echo ${NAME}':' "not deconfiguring network interfaces: network swap still mounted."
|
|
exit 0
|
|
;;
|
|
esac
|
|
done < /proc/swaps
|
|
}
|
|
|
|
ifup_hotplug () {
|
|
if [ -d /sys/class/net ]
|
|
then
|
|
ifaces=$(for iface in $(ifquery --list --allow=hotplug 2>/dev/null)
|
|
do
|
|
link=${iface##:*}
|
|
link=${link##.*}
|
|
if [ -e "/sys/class/net/$link" ] && [ "$(cat /sys/class/net/$link/operstate)" = up ]
|
|
then
|
|
echo "$iface"
|
|
fi
|
|
done)
|
|
if [ -n "$ifaces" ]
|
|
then
|
|
ifup $ifaces "$@" || true
|
|
fi
|
|
fi
|
|
}
|
|
|
|
ifupdown_init() {
|
|
[ ! -e /run/network ] && mkdir -p /run/network &>/dev/null
|
|
[ ! -e /etc/network/run ] && \
|
|
ln -sf /run/network /etc/network/run &>/dev/null
|
|
}
|
|
|
|
case "$1" in
|
|
start)
|
|
ifupdown_init
|
|
if [ "$CONFIGURE_INTERFACES" = no ]
|
|
then
|
|
echo ${NAME}':' "Not configuring network interfaces, see /etc/default/networking"
|
|
exit 0
|
|
fi
|
|
set -f
|
|
exclusions=$(process_exclusions)
|
|
perfoptions=$(perf_options)
|
|
echo ${NAME}':' "Configuring network interfaces"
|
|
ifup -a $EXTRA_ARGS $exclusions $perfoptions
|
|
;;
|
|
|
|
stop)
|
|
ifupdown_init
|
|
check_network_file_systems
|
|
check_network_swap
|
|
exclusions=$(process_exclusions)
|
|
|
|
echo ${NAME}':' "Deconfiguring network interfaces"
|
|
ifdown -a $EXTRA_ARGS
|
|
;;
|
|
|
|
reload)
|
|
|
|
ifupdown_init
|
|
echo ${NAME}':' "Reloading network interfaces configuration"
|
|
|
|
ifreload -a $EXTRA_ARGS
|
|
;;
|
|
|
|
*)
|
|
echo ${NAME}':' "Usage: $0 {start|stop|reload}"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
exit 0
|