diff options
author | Olav Vitters <olav@vitters.nl> | 2020-07-26 21:46:44 +0200 |
---|---|---|
committer | Olav Vitters <olav@vitters.nl> | 2020-07-26 21:46:44 +0200 |
commit | 244c9a00ae9a0dc62156aeb8781c2b22da0ad96e (patch) | |
tree | c0d76ed490862837a8a37bb61ed8e653e5cc2558 /network-scripts/ifdown | |
parent | d0d18c6de12efeba25eb41d7cf207037027e4964 (diff) | |
parent | 6ca701a23c74b245f35750149a22f7d21805a8e0 (diff) | |
download | initscripts-244c9a00ae9a0dc62156aeb8781c2b22da0ad96e.tar initscripts-244c9a00ae9a0dc62156aeb8781c2b22da0ad96e.tar.gz initscripts-244c9a00ae9a0dc62156aeb8781c2b22da0ad96e.tar.bz2 initscripts-244c9a00ae9a0dc62156aeb8781c2b22da0ad96e.tar.xz initscripts-244c9a00ae9a0dc62156aeb8781c2b22da0ad96e.zip |
Merge tag '10.04' into distro/mga
10.04 release
Diffstat (limited to 'network-scripts/ifdown')
-rwxr-xr-x | network-scripts/ifdown | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/network-scripts/ifdown b/network-scripts/ifdown new file mode 100755 index 00000000..72cc49d5 --- /dev/null +++ b/network-scripts/ifdown @@ -0,0 +1,79 @@ +#!/bin/bash + +unset WINDOW # defined by screen, conflicts with our usage + +. /etc/init.d/functions + +cd /etc/sysconfig/network-scripts +. ./network-functions + +[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network + +CONFIG=$1 + +[ -z "$CONFIG" ] && { + echo $"usage: ifdown <configuration>" >&2 + exit 1 +} + +need_config "${CONFIG}" + +[ -f "$CONFIG" ] || { + echo $"usage: ifdown <configuration>" >&2 + exit 1 +} + +if [ $UID != 0 ]; then + if [ -x /usr/sbin/usernetctl ]; then + source_config + if /usr/sbin/usernetctl ${CONFIG} report ; then + exec /usr/sbin/usernetctl ${CONFIG} down + fi + fi + echo $"Users cannot control this device." >&2 + exit 1 +fi + +source_config + +if ! is_true ${DEPRECATION_WARNING_ISSUED}; then + net_log $"You are using 'ifdown' script provided by 'network-scripts', which are now deprecated." warning ifdown >&2 + net_log $"'network-scripts' will be removed from distribution in near future." warning ifdown >&2 + net_log $"It is advised to switch to 'NetworkManager' instead - it provides 'ifup/ifdown' scripts as well." warning ifdown >&2 +fi + +if [ -n "$IN_HOTPLUG" ] && [ "${HOTPLUG}" = "no" -o "${HOTPLUG}" = "NO" ] +then + exit 0 +fi + +if is_true "$_use_nm"; then + if [ -n "$UUID" -a -z "$DEVICE" ]; then + DEVICE=$(nmcli -t --fields uuid,device con show --active | awk -F ':' "\$1 == \"$UUID\" { print \$2 }") + fi + if [ -n "$DEVICE" ] && ! is_nm_device_unmanaged "$DEVICE" ; then + if ! LC_ALL=C nmcli -t -f STATE,DEVICE dev status | grep -Eq "^(failed|disconnected|unmanaged|unavailable):$DEVICE$"; then + nmcli dev disconnect "$DEVICE" + exit $? + fi + exit 0 + fi + echo $"$0: interface ${CONFIG} is controlled by NetworkManager; skipping." >&2 + exit 0 +fi + +if [ -x /sbin/ifdown-pre-local ]; then + /sbin/ifdown-pre-local ${DEVICE} +fi + +OTHERSCRIPT="/etc/sysconfig/network-scripts/ifdown-${DEVICETYPE}" + +if [ ! -x ${OTHERSCRIPT} ]; then + OTHERSCRIPT="/etc/sysconfig/network-scripts/ifdown-${TYPE}" +fi + +if [ ! -x ${OTHERSCRIPT} ]; then + OTHERSCRIPT="/etc/sysconfig/network-scripts/ifdown-eth" +fi + +exec ${OTHERSCRIPT} ${CONFIG} $2 |