0815f289e0
OBS-URL: https://build.opensuse.org/package/show/network:dhcp/dhcp?expand=0&rev=b08c0d269b6009aab736242b60dffd9f
114 lines
3.2 KiB
Bash
114 lines
3.2 KiB
Bash
#! /bin/bash
|
|
#
|
|
# dhcpd-restart-hook - script to restart dhcpd on virtual interfaces
|
|
#
|
|
# Copyright (C) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
|
#
|
|
# Author(s): Marius Tomaschewski <mt@suse.de>, 2009
|
|
#
|
|
# This program is free software; you can redistribute it and/or
|
|
# modify it under the terms of the GNU General Public License
|
|
# version 2 as published by the Free Software Foundation.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program; if not, write to the Free Software
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
#
|
|
# Please send feedback via http://www.suse.de/feedback
|
|
#
|
|
|
|
set -e
|
|
|
|
unset ${!LC_*} LANUGUAGE
|
|
export LANG=POSIX
|
|
export PATH=/sbin:/usr/sbin:/usr/bin:/bin
|
|
|
|
SCRIPTNAME=${0##*/}
|
|
|
|
usage () {
|
|
echo "usage: $SCRIPTNAME [<config>] <interface> [-o <options>]"
|
|
echo ""
|
|
echo "Any options are ignored"
|
|
exit $R_USAGE
|
|
}
|
|
|
|
R_INTERNAL=1 # internal error, e.g. no config or missing scripts
|
|
cd /etc/sysconfig/network || exit $R_INTERNAL
|
|
|
|
case $1 in ""|-h|*help*) usage ;; esac
|
|
INTERFACE="$1"
|
|
if test "x$2" != x -a "x$2" != "x-o" ; then
|
|
CONFIG=$INTERFACE
|
|
INTERFACE="$2"
|
|
else
|
|
CONFIG=$INTERFACE
|
|
fi
|
|
|
|
|
|
. /etc/sysconfig/network/config
|
|
. /etc/sysconfig/network/scripts/functions
|
|
|
|
. /etc/sysconfig/dhcpd 2>/dev/null
|
|
. /etc/sysconfig/network/ifcfg-"$CONFIG" 2>/dev/null || true
|
|
|
|
: ${DHCPD_IFUP_RESTART:=auto}
|
|
|
|
iface_needs_restart()
|
|
{
|
|
test -d /sys/class/net/$1/bridge -o \
|
|
-d /sys/class/net/$1/bonding -o \
|
|
-f /proc/net/vlan/$1
|
|
}
|
|
|
|
case "$0" in
|
|
*if-up.d*)
|
|
#
|
|
# don't do anything if we are disabled either
|
|
# in the /etc/sysconfig/dhcpd or per interface
|
|
# in the /etc/sysconfig/network/ifcfg-"$CONFIG"
|
|
#
|
|
test "$DHCPD_IFUP_RESTART" = no && exit 0
|
|
|
|
# don't restart for loopback interface
|
|
case $INTERFACE in (lo) exit 0 ;; esac
|
|
|
|
restart_needed=$DHCPD_IFUP_RESTART
|
|
if test -n "$DHCPD_INTERFACE" \
|
|
-a "$restart_needed" != yes ;
|
|
then
|
|
for I in $DHCPD_INTERFACE ; do
|
|
test -n "$I" || continue
|
|
|
|
# don't restart when _one_ involved
|
|
# interface is not available/up yet
|
|
is_iface_up $I || exit 0
|
|
|
|
# check if this interface is involved
|
|
if test "$I" = "$INTERFACE" ; then
|
|
|
|
# check if a restart is needed
|
|
if iface_needs_restart $I ; then
|
|
restart_needed=yes
|
|
fi
|
|
fi
|
|
done
|
|
fi
|
|
|
|
if test "$restart_needed" = yes ; then
|
|
/etc/init.d/dhcpd try-restart
|
|
fi
|
|
;;
|
|
*if-down.d*)
|
|
# don't do anything
|
|
;;
|
|
*)
|
|
echo "$SCRIPTNAME: don't know what to do" >&2
|
|
;;
|
|
esac
|
|
|