#!/bin/sh -u

# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1

# Source function library.
. /etc/init.d/functions
. shell-config

NM_DOWN_CONTROLLED=
NM_SYSCTL_CONF=

# Source config.
SourceIfNotEmpty /etc/sysconfig/NetworkManager

IFDOWN=/sbin/ifdown

if is_yes "$NM_DOWN_CONTROLLED" && [ -d /etc/net/ifaces/ ]; then
	for i in /etc/net/ifaces/*; do
		iface="${i##*/}"
		case "$iface" in
			default|unknown|lo) continue;;
		esac
		nm_controlled="$(shell_config_get "$i/options" NM_CONTROLLED)"
		disabled="$(shell_config_get "$i/options" DISABLED)"
		if [ -n "$nm_controlled" ] && is_yes "$nm_controlled"; then
			if [ -z "$disabled" ] || is_no "$disabled"; then
				[ -x "$IFDOWN" ] && action "Taking down $iface:" $IFDOWN "$iface"
			fi
		fi
	done
fi

if [ -n "$NM_SYSCTL_CONF" ]; then
	action "Setting network parameters:" sysctl -e -p "$NM_SYSCTL_CONF" ||:
fi
