|
Server : Apache System : Linux iZ6xhqomji47p1Z 5.10.134-15.al8.x86_64 #1 SMP Thu Jul 20 00:44:04 CST 2023 x86_64 User : www ( 1000) PHP Version : 8.1.30 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv Directory : /proc/self/root/sbin/ |
#!/bin/bash
CONFIG="$1"
if [ -z "${CONFIG}" ] ; then
echo $"Usage: ifup <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\`
Activate the desired profile with \`nmcli connection up \"\$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 up filename "$f" \
&& exit 0
usage_and_fail "Failure to activate file \"$CONFIG\""
done
IFS=$'\n '
UUIDS=( $(nmcli -g connection.uuid connection show "$CONFIG" 2>/dev/null) )
IFS="$OLD_IFS"
if [ "${#UUIDS[@]}" -eq 1 ] ; then
nmcli connection up uuid "${UUIDS[0]}" \
&& exit 0
usage_and_fail "Failure to activate profile \"$CONFIG\" (uuid ${UUIDS[0]})"
fi
usage_and_fail "No suitable profile \"$CONFIG\" found"