aboutsummaryrefslogtreecommitdiffstats
path: root/sysconfig/network-scripts/ifdown
blob: f2c13086d2593a6e54a4e85717adccbf18dace46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash

unset WINDOW # defined by screen, conflicts with our usage

. /etc/init.d/functions

cd /etc/sysconfig/network-scripts
. ./network-functions

[ -f ../network ] && . ../network

CONFIG=$1

[ -z "$CONFIG" ] && {
    echo $"usage: ifdown <device name>" >&2
    exit 1
}

need_config "${CONFIG}"

[ -f "$CONFIG" ] || {
    echo $"usage: ifdown <device name>" >&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 [ -n "$IN_HOTPLUG" ] && [ "${HOTPLUG}" = "no" -o "${HOTPLUG}" = "NO" ]
then
    exit 0
fi

if [ "$USE_NM" = "true" ]; then
    if [ -n "$UUID" -a -z "$DEVICE" ]; then
	DEVICE=$(nmcli -t --fields uuid,devices con status | awk -F ':' "\$1 == \"$UUID\" { print \$2 }")
    fi
    if [ -n "$DEVICE" ] && ! is_nm_device_unmanaged "$DEVICE" ; then
	nmcli dev disconnect iface "$DEVICE"
	exit $?
    fi
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