diff options
author | DJ Lucas <dj@linuxfromscratch.org> | 2011-05-15 03:17:07 +0000 |
---|---|---|
committer | DJ Lucas <dj@linuxfromscratch.org> | 2011-05-15 03:17:07 +0000 |
commit | 63a2c2d454e05553cb83f3656108838f46975ba6 (patch) | |
tree | 1a025d83023b0dcd87259c0b78818b3e2c338692 /lsb-bootscripts/lib/network-services/ipv4-static | |
parent | dcae1d7df3deb6ae9a24b90d83f66feff49c93b0 (diff) |
Moved BOOK/bootscripts/contrib/lsb-v3 to BOOK/lsb-bootscripts.
git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@9538 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689
Diffstat (limited to 'lsb-bootscripts/lib/network-services/ipv4-static')
-rw-r--r-- | lsb-bootscripts/lib/network-services/ipv4-static | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/lsb-bootscripts/lib/network-services/ipv4-static b/lsb-bootscripts/lib/network-services/ipv4-static new file mode 100644 index 000000000..417d22de6 --- /dev/null +++ b/lsb-bootscripts/lib/network-services/ipv4-static @@ -0,0 +1,80 @@ +#!/bin/sh +######################################################################## +# Begin $NETWORK_DEVICES/services/ipv4-static +# +# Description : IPV4 Static Boot Script +# +# Authors : Nathan Coulson - nathan@linuxfromscratch.org +# Kevin P. Fleming - kpfleming@linuxfromscratch.org +# +# Version : 00.00 +# +# Notes : +# +######################################################################## + +. /lib/lsb/init-functions +. ${IFCONFIG} + +if [ -z "${IP}" ]; then + log_failure_msg "IP variable missing from ${IFCONFIG}, cannot continue." + exit 1 +fi + +if [ -z "${PREFIX}" -a -z "${PEER}" ]; then + log_warning_msg "PREFIX variable missing from ${IFCONFIG}, assuming 24." + PREFIX=24 + args="${args} ${IP}/${PREFIX}" +elif [ -n "${PREFIX}" -a -n "${PEER}" ]; then + log_failure_msg "PREFIX and PEER both specified in ${IFCONFIG}, cannot continue." + exit 1 +elif [ -n "${PREFIX}" ]; then + args="${args} ${IP}/${PREFIX}" +elif [ -n "${PEER}" ]; then + args="${args} ${IP} peer ${PEER}" +fi + +if [ -n "${BROADCAST}" ]; then + args="${args} broadcast ${BROADCAST}" +fi + +if [ -n "${SOURCE}" ]; then + args="${args} src ${SOURCE}" +fi + +case "${2}" in + up) + MESSAGE="Adding IPv4 address ${IP} to the ${1} interface..." + ip addr add ${args} dev ${1} + evaluate_retval + + if [ -n "${GATEWAY}" ]; then + if ip route | grep -q default; then + log_warning_msg "Gateway already setup; skipping." ${WARNING} + else + MESSAGE="Setting up default gateway..." + ip route add default via ${GATEWAY} dev ${1} + evaluate_retval + fi + fi + ;; + + down) + if [ -n "${GATEWAY}" ]; then + MESSAGE="Removing default gateway..." + ip route del default + evaluate_retval + fi + + MESSAGE="Removing IPv4 address ${IP} from the ${1} interface..." + ip addr del ${args} dev ${1} + evaluate_retval + ;; + + *) + echo "Usage: ${0} [interface] {up|down}" + exit 1 + ;; +esac + +# End $NETWORK_DEVICES/services/ipv4-static |