source: bootscripts/lfs/sysconfig/network-devices/services/ipv4-static@ 70953e8

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 70953e8 was 163a6701, checked in by Jim Gifford <clfs@…>, 19 years ago

r720@server (orig r718): jim | 2005-11-18 08:06:26 -0800
Added bootscripts to cross-lfs svn

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