source: systemd-units/lfs/lib/services/ipv4-static@ 01479e6

7.5-systemd 7.6-systemd 7.7-systemd 7.8-systemd 7.9-systemd
Last change on this file since 01479e6 was 01479e6, checked in by Krejzi <krejzi@…>, 11 years ago

Import new bootscripts package.

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/systemd/BOOK@10278 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 "${BROADCAST}" ]; then
40 args="${args} broadcast ${BROADCAST}"
41fi
42
43case "${2}" in
44 up)
45 if [ "$(ip addr show ${1} 2>/dev/null | grep ${IP}/)" = "" ]; then
46
47 # Cosmetic output not needed for multiple services
48 if ! $(echo ${SERVICE} | grep -q " "); then
49 log_info_msg2 "\n" # Terminate the previous message
50 fi
51
52 log_info_msg "Adding IPv4 address ${IP} to the ${1} interface..."
53 ip addr add ${args} dev ${1}
54 evaluate_retval
55 else
56 log_warning_msg "Cannot add IPv4 address ${IP} to ${1}. Already present."
57 fi
58 ;;
59
60 down)
61 if [ "$(ip addr show ${1} 2>/dev/null | grep ${IP}/)" != "" ]; then
62 log_info_msg "Removing IPv4 address ${IP} from the ${1} interface..."
63 ip addr del ${args} dev ${1}
64 evaluate_retval
65 fi
66
67 if [ -n "${GATEWAY}" ]; then
68 # Only remove the gateway if there are no remaining ipv4 addresses
69 if [ "$(ip addr show ${1} 2>/dev/null | grep 'inet ')" != "" ]; then
70 log_info_msg "Removing default gateway..."
71 ip route del default
72 evaluate_retval
73 fi
74 fi
75 ;;
76
77 *)
78 echo "Usage: ${0} [interface] {up|down}"
79 exit 1
80 ;;
81esac
82
83# End /lib/services/ipv4-static
Note: See TracBrowser for help on using the repository browser.