source: bootscripts/lfs/sysconfig/network-devices/services/ipv4-static@ 0cda898

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 0cda898 was 0cda898, checked in by Bruce Dubbs <bdubbs@…>, 13 years ago

Rewrite bootscripts and Chaper 7

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

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