HEX
Server: Apache/2.4.68 (codeit) OpenSSL/4.0.1
System: Linux societies-web 5.4.17-2136.353.3.el8uek.x86_64 #3 SMP Thu Feb 12 09:46:56 PST 2026 x86_64
User: yles (1028)
PHP: 8.3.31
Disabled: exec,shell_exec,passthru,system,proc_open,popen,curl_exec,curl_multi_exec,parse_ini_file,show_source,symlink,pcntl_exec
Upload Files
File: //sbin/ifdown
#!/bin/bash

CONFIG="$1"

if [ -z "${CONFIG}" ] ; then
    echo $"Usage: ifdown <device name>" >&2
    exit 1
fi

usage_and_fail() {
    cat <<EOF >&2
$1!

See all profiles with \`nmcli connection\`.
Reload files from disk with \`nmcli connection reload\`
Deactivate the desired profile with \`nmcli connection down \"\$NAME\"\`
EOF
    exit 1
}

OLD_IFS="$IFS"

re='^/etc/sysconfig/network-scripts/ifcfg-[^/]+$'
for f in "/etc/sysconfig/network-scripts/ifcfg-$CONFIG" "/etc/sysconfig/network-scripts/$CONFIG" ; do
    [[ "$f" =~ $re ]] || continue
    [ -f "$f" ] || continue

    nmcli connection load "$f" \
    && nmcli connection down filename "$f" \
    && exit 0

    usage_and_fail "Failure to deactivate file \"$CONFIG\""
done

IFS=$'\n '
APATHS=( $(nmcli -g GENERAL.DBUS-PATH connection show --active "$CONFIG" 2>/dev/null) )
IFS="$OLD_IFS"
if [ "${#APATHS[@]}" -eq 1 ] ; then
    nmcli connection down apath "${APATHS[0]}" \
    && exit 0
    usage_and_fail "Failure to deactivate profile \"$CONFIG\" (apath ${APATHS[@]})"
fi

usage_and_fail "No suitable profile \"$CONFIG\" found"