source: bootscripts-standard/clfs/sysconfig/network-devices/services/ipv4-static-route@ 006050c

Last change on this file since 006050c was 1d02f01, checked in by Jim Gifford <clfs@…>, 17 years ago

Merged Updates from BLFS/LFS SVNs

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