source: bootscripts/lfs/sysconfig/network-devices/services/ipv4-static-route@ a2e555d

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 a2e555d 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.0 KB
Line 
1#!/bin/sh
2########################################################################
3# Begin /lib/boot/ipv4-static-route
4#
5# Description : IPV4 Static Route Script
6#
7# Authors : Kevin P. Fleming - kpfleming@linuxfromscratch.org
8# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
9#
10# Version : LFS 7.0
11#
12########################################################################
13
14. /lib/boot/functions
15. ${IFCONFIG}
16
17case "${TYPE}" in
18 ("" | "network")
19 need_ip=1
20 need_gateway=1
21 ;;
22
23 ("default")
24 need_gateway=1
25 args="${args} default"
26 desc="default"
27 ;;
28
29 ("host")
30 need_ip=1
31 ;;
32
33 ("unreachable")
34 need_ip=1
35 args="${args} unreachable"
36 desc="unreachable "
37 ;;
38
39 (*)
40 boot_mesg "Unknown route type (${TYPE}) in ${IFCONFIG}, cannot continue." ${FAILURE}
41 echo_failure
42 exit 1
43 ;;
44esac
45
46if [ -n "${need_ip}" ]; then
47 if [ -z "${IP}" ]; then
48 boot_mesg "IP variable missing from ${IFCONFIG}, cannot continue." ${FAILURE}
49 echo_failure
50 exit 1
51 fi
52
53 if [ -z "${PREFIX}" ]; then
54 boot_mesg "PREFIX variable missing from ${IFCONFIG}, cannot continue." ${FAILURE}
55 echo_failure
56 exit 1
57 fi
58
59 args="${args} ${IP}/${PREFIX}"
60 desc="${desc}${IP}/${PREFIX}"
61fi
62
63if [ -n "${need_gateway}" ]; then
64 if [ -z "${GATEWAY}" ]; then
65 boot_mesg "GATEWAY variable missing from ${IFCONFIG}, cannot continue." ${FAILURE}
66 echo_failure
67 exit 1
68 fi
69 args="${args} via ${GATEWAY}"
70fi
71
72if [ -n "${SOURCE}" ]; then
73 args="${args} src ${SOURCE}"
74fi
75
76case "${2}" in
77 up)
78 boot_mesg "Adding '${desc}' route to the ${1} interface..."
79 ip route add ${args} dev ${1}
80 evaluate_retval
81 ;;
82
83 down)
84 boot_mesg "Removing '${desc}' route from the ${1} interface..."
85 ip route del ${args} dev ${1}
86 evaluate_retval
87 ;;
88
89 *)
90 echo "Usage: ${0} [interface] {up|down}"
91 exit 1
92 ;;
93esac
94
95# End /bib/boot/ipv4-static-route
Note: See TracBrowser for help on using the repository browser.