source: lsb-bootscripts/lib/network-services/ipv4-static@ 5de4ea07

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 11.1 11.1-rc1 11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 7.0 7.1 7.2 7.3 7.4 7.5 7.5-systemd 7.6 7.6-systemd 7.7 7.7-systemd 7.8 7.8-systemd 7.9 7.9-systemd 8.0 8.1 8.2 8.3 8.4 9.0 9.1 arm bdubbs/gcc13 ml-11.0 multilib renodr/libudev-from-systemd s6-init trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/lfs-next xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since 5de4ea07 was 5de4ea07, checked in by DJ Lucas <dj@…>, 13 years ago

Fixed Begin and End on network services.

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@9553 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 1.8 KB
Line 
1#!/bin/sh
2########################################################################
3# Begin /lib/network-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#
10# Version : 00.00
11#
12# Notes :
13#
14########################################################################
15
16. /lib/lsb/init-functions
17. ${IFCONFIG}
18
19if [ -z "${IP}" ]; then
20 log_failure_msg "IP variable missing from ${IFCONFIG}, cannot continue."
21 exit 1
22fi
23
24if [ -z "${PREFIX}" -a -z "${PEER}" ]; then
25 log_warning_msg "PREFIX variable missing from ${IFCONFIG}, assuming 24."
26 PREFIX=24
27 args="${args} ${IP}/${PREFIX}"
28elif [ -n "${PREFIX}" -a -n "${PEER}" ]; then
29 log_failure_msg "PREFIX and PEER both specified in ${IFCONFIG}, cannot continue."
30 exit 1
31elif [ -n "${PREFIX}" ]; then
32 args="${args} ${IP}/${PREFIX}"
33elif [ -n "${PEER}" ]; then
34 args="${args} ${IP} peer ${PEER}"
35fi
36
37if [ -n "${BROADCAST}" ]; then
38 args="${args} broadcast ${BROADCAST}"
39fi
40
41if [ -n "${SOURCE}" ]; then
42 args="${args} src ${SOURCE}"
43fi
44
45case "${2}" in
46 up)
47 MESSAGE="Adding IPv4 address ${IP} to the ${1} interface..."
48 ip addr add ${args} dev ${1}
49 evaluate_retval
50
51 if [ -n "${GATEWAY}" ]; then
52 if ip route | grep -q default; then
53 log_warning_msg "Gateway already setup; skipping." ${WARNING}
54 else
55 MESSAGE="Setting up default gateway..."
56 ip route add default via ${GATEWAY} dev ${1}
57 evaluate_retval
58 fi
59 fi
60 ;;
61
62 down)
63 if [ -n "${GATEWAY}" ]; then
64 MESSAGE="Removing default gateway..."
65 ip route del default
66 evaluate_retval
67 fi
68
69 MESSAGE="Removing IPv4 address ${IP} from the ${1} interface..."
70 ip addr del ${args} dev ${1}
71 evaluate_retval
72 ;;
73
74 *)
75 echo "Usage: ${0} [interface] {up|down}"
76 exit 1
77 ;;
78esac
79
80# End /lib/network-services/ipv4-static
Note: See TracBrowser for help on using the repository browser.