2012-10-04 15:33:40 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# In the interest of keeping the KVP daemon code free of distro specific
|
|
|
|
# information; the kvp daemon code invokes this external script to configure
|
|
|
|
# the interface.
|
|
|
|
#
|
|
|
|
# The only argument to this script is the configuration file that is to
|
|
|
|
# be used to configure the interface.
|
|
|
|
#
|
|
|
|
# Here is the format of the ip configuration file:
|
|
|
|
#
|
|
|
|
# HWADDR=macaddr
|
|
|
|
# IF_NAME=interface name
|
|
|
|
# DHCP=yes (This is optional; if yes, DHCP is configured)
|
|
|
|
#
|
|
|
|
# IPADDR=ipaddr1
|
|
|
|
# IPADDR_1=ipaddr2
|
|
|
|
# IPADDR_x=ipaddry (where y = x + 1)
|
|
|
|
#
|
|
|
|
# NETMASK=netmask1
|
|
|
|
# NETMASK_x=netmasky (where y = x + 1)
|
|
|
|
#
|
|
|
|
# GATEWAY=ipaddr1
|
|
|
|
# GATEWAY_x=ipaddry (where y = x + 1)
|
|
|
|
#
|
|
|
|
# DNSx=ipaddrx (where first DNS address is tagged as DNS1 etc)
|
|
|
|
#
|
|
|
|
# IPV6 addresses will be tagged as IPV6ADDR, IPV6 gateway will be
|
|
|
|
# tagged as IPV6_DEFAULTGW and IPV6 NETMASK will be tagged as
|
|
|
|
# IPV6NETMASK.
|
|
|
|
#
|
|
|
|
# The host can specify multiple ipv4 and ipv6 addresses to be
|
|
|
|
# configured for the interface. Furthermore, the configuration
|
|
|
|
# needs to be persistent. A subsequent GET call on the interface
|
|
|
|
# is expected to return the configuration that is set via the SET
|
|
|
|
# call.
|
|
|
|
#
|
2012-10-26 17:14:16 +02:00
|
|
|
cfg=$1
|
|
|
|
if ! test -f "${cfg}"
|
2012-10-04 15:33:40 +02:00
|
|
|
then
|
2012-10-26 17:14:16 +02:00
|
|
|
: expect configuration datafile as first argument
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
#
|
|
|
|
(
|
|
|
|
unset DHCP
|
|
|
|
unset IF_NAME
|
|
|
|
. "$1"
|
|
|
|
if test -z "${IF_NAME}"
|
|
|
|
then
|
|
|
|
echo "Missing IF_NAME= in ${cfg}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
#
|
|
|
|
t=`mktemp`
|
|
|
|
if test -z "${t}"
|
|
|
|
then
|
|
|
|
exit 1
|
2012-10-04 15:33:40 +02:00
|
|
|
fi
|
|
|
|
|
2012-10-26 17:14:16 +02:00
|
|
|
_exit() {
|
|
|
|
rm -f "${t}"
|
|
|
|
}
|
|
|
|
trap _exit EXIT
|
|
|
|
#
|
|
|
|
cat >> "${t}" <<_EOF_
|
|
|
|
# contents from $0 $*
|
|
|
|
`cat "${cfg}"`
|
|
|
|
#
|
|
|
|
# additional options:
|
|
|
|
STARTMODE=auto
|
|
|
|
_EOF_
|
2012-10-04 15:33:40 +02:00
|
|
|
|
2012-10-26 17:14:16 +02:00
|
|
|
if test "${DHCP}" = "yes"
|
|
|
|
then
|
|
|
|
echo "BOOTPROTO=dhcp" >> ${t};
|
|
|
|
fi
|
2012-10-04 15:33:40 +02:00
|
|
|
|
2012-10-26 17:14:16 +02:00
|
|
|
echo "$0: working on network interface ifcfg-${IF_NAME}"
|
|
|
|
cp -b ${t} /etc/sysconfig/network/ifcfg-${IF_NAME}
|
|
|
|
ifdown ${IF_NAME} -o hotplug
|
|
|
|
ifup ${IF_NAME} -o hotplug
|
|
|
|
) 2>&1 | logger -t "${0##*/}[$PPID / $$]"
|