source: bootscripts/lfs/lib/services/ipv4-static@ 4a8482f

multilib-10.1
Last change on this file since 4a8482f was 1fa2099, checked in by Thomas Trepl <thomas@…>, 5 years ago

Initial creation of multilib branch

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/multilib@11565 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100755
File size: 2.3 KB
Line 
1#!/bin/sh
2########################################################################
3# Begin /lib/services/ipv4-static
4#
5# Description : IPV4 Static Boot Script
6#
7# Authors : Nathan Coulson - nathan@linuxfromscratch.org
8# Kevin P. Fleming - kpfleming@linuxfromscratch.org
9# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
10#
11# Version : LFS 7.0
12#
13########################################################################
14
15. /lib/lsb/init-functions
16. ${IFCONFIG}
17
18if [ -z "${IP}" ]; then
19 log_failure_msg "\nIP variable missing from ${IFCONFIG}, cannot continue."
20 exit 1
21fi
22
23if [ -z "${PREFIX}" -a -z "${PEER}" ]; then
24 log_warning_msg "\nPREFIX variable missing from ${IFCONFIG}, assuming 24."
25 PREFIX=24
26 args="${args} ${IP}/${PREFIX}"
27
28elif [ -n "${PREFIX}" -a -n "${PEER}" ]; then
29 log_failure_msg "\nPREFIX and PEER both specified in ${IFCONFIG}, cannot continue."
30 exit 1
31
32elif [ -n "${PREFIX}" ]; then
33 args="${args} ${IP}/${PREFIX}"
34
35elif [ -n "${PEER}" ]; then
36 args="${args} ${IP} peer ${PEER}"
37fi
38
39if [ -n "${LABEL}" ]; then
40 args="${args} label ${LABEL}"
41fi
42
43if [ -n "${BROADCAST}" ]; then
44 args="${args} broadcast ${BROADCAST}"
45fi
46
47case "${2}" in
48 up)
49 if [ "$(ip addr show ${1} 2>/dev/null | grep ${IP}/)" = "" ]; then
50
51 # Cosmetic output
52 if ! $(echo ${SERVICE} | grep -q " "); then
53 log_info_msg2 "\n" # Terminate the previous message
54 fi
55
56 log_info_msg "Adding IPv4 address ${IP} to the ${1} interface..."
57 ip addr add ${args} dev ${1}
58 evaluate_retval
59 else
60 log_warning_msg "Cannot add IPv4 address ${IP} to ${1}. Already present."
61 fi
62 ;;
63
64 down)
65 if [ "$(ip addr show ${1} 2>/dev/null | grep ${IP}/)" != "" ]; then
66 log_info_msg "Removing IPv4 address ${IP} from the ${1} interface..."
67 ip addr del ${args} dev ${1}
68 evaluate_retval
69 fi
70
71 if [ -n "${GATEWAY}" ]; then
72 # Only remove the gateway if there are no remaining ipv4 addresses
73 if [ "$(ip addr show ${1} 2>/dev/null | grep 'inet ')" != "" ]; then
74 log_info_msg "Removing default gateway..."
75 ip route del default
76 evaluate_retval
77 fi
78 fi
79 ;;
80
81 *)
82 echo "Usage: ${0} [interface] {up|down}"
83 exit 1
84 ;;
85esac
86
87# End /lib/services/ipv4-static
Note: See TracBrowser for help on using the repository browser.