| Server IP : 20.75.53.88 / Your IP : 216.73.217.138 [ Web Server : Apache System : Linux VMRALP-3 4.4.0-256-generic #290~14.04.1-Ubuntu SMP Thu Jun 20 09:24:50 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29+esm15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,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, Domains : 3 Domains MySQL : ON | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/sbin/ |
Upload File : |
#!/bin/bash
# This example script retrieves the DHCP state of a given interface.
# In the interest of keeping the KVP daemon code free of distro specific
# information; the kvp daemon code invokes this external script to gather
# DHCP setting for the specific interface.
#
# Input: Name of the interface
#
# Output: The script prints the string "Enabled" to stdout to indicate
# that DHCP is enabled on the interface. If DHCP is not enabled,
# the script prints the string "Disabled" to stdout.
#
# Each Distro is expected to implement this script in a distro specific
# fashion.
#set -x
IF_FILE="/etc/network/interfaces"
NMCMD="nmcli"
function checknetworkmanager {
#Assumes if $NMCMD exists, inteface exists and interface is not
# in $IF_FILE then dhcp is being used by NM
if hash $NMCMD >/dev/null 2>&1 ; then
if $NMCMD dev status |grep -q $1 ; then
echo "Enabled"
else
echo "Disabled"
fi
else
#Give up
echo "Disabled"
fi
}
if [ -z $1 ] ; then echo "Disabled"; exit; fi
if [ -e $IF_FILE ]; then
if grep -v -e "^#" $IF_FILE|grep -q $1 ; then
#interface exists so
if grep -q -e $1\.\*dhcp $IF_FILE; then
echo "Enabled"; exit;
else
echo "Disabled"; exit;
fi
else
checknetworkmanager $1
exit
fi
else
checknetworkmanager $1
exit
fi