The Linux network-functions script
The ifup script invokes the script network-functions:
# This is not a shell script; it provides functions to network scripts
# that source it.
source_config ()
{
DEVNAME=`basename $CONFIG | sed 's/^ifcfg-//g'`
if basename $CONFIG | grep '[^g]-' >/dev/null 2>&1 ; then
PARENTCONFIG=`echo $CONFIG | sed 's/-[^-]*$//g'`
PARENTDEVNAME=`basename $PARENTCONFIG | sed 's/^ifcfg-//g'`
[ -f $PARENTCONFIG ] || {
echo "Missing config file $PARENTCONFIG." >&2
exit 1
}
. $PARENTCONFIG
fi
. $CONFIG
}
do_netreport ()
{
# Notify programs that have requested notification
( cd /var/run/netreport || exit
for i in * ; do
[ -f $i ] && \
kill -SIGIO $i >/dev/null 2>&1 || \
rm -f $i >/dev/null 2>&1
done
)
}
need_hostname()
{
if [ "`hostname`" = "(none)" -o "`hostname`" = "localhost" -o \
"`hostname`" = "localhost.localdomain" ]; then
NEEDHOSTNAME=yes
else
unset NEEDHOSTNAME
fi
}
set_hostname()
{
echo "$1" > /etc/HOSTNAME
hostname $1
if ! grep search /etc/resolv.conf >/dev/null 2>&1; then
domain=`echo $1 | sed 's/^[^\.]*\.//'`
echo "search $domain" >> /etc/resolv.conf
fi
}
check_device_down ()
{
if ifconfig ${DEVICE} | grep UP >/dev/null 2>&1 ; then
retcode=1
else
retcode=0
fi
return $retcode
}
|