]> git.ipfire.org Git - ipfire-2.x.git/blob - src/initscripts/system/static-routes
unbound: Drop certificates for local control connection
[ipfire-2.x.git] / src / initscripts / system / static-routes
1 #!/bin/bash
2
3 . /etc/sysconfig/rc
4 . ${rc_functions}
5
6
7 function init_table() {
8 # Check if table does already exist. If not we add it.
9 if (ip rule | grep -q "static" >/dev/null 2>&1); then
10 return
11 fi
12
13 ip rule add table static
14 }
15
16 function create_all_routes() {
17 local file=${1}
18 shift
19
20 # Remote all routes.
21 ip route flush table static >/dev/null 2>&1
22
23 local status
24 local network
25 local gateway
26 local remark
27
28 # Read all routes from the configuration file and add the enabled ones
29 # immediately.
30 while IFS=, read status network gateway remark; do
31 [ "${status}" = "on" ] || continue
32
33 if [ -z "${network}" -o -z "${gateway}" ]; then
34 # Silently skipping invalid routes.
35 continue
36 fi
37
38 ip route add ${network} via ${gateway} table static proto static
39 done < ${file}
40 }
41
42 CONFIGFILE="/var/ipfire/main/routing"
43
44 case "${1}" in
45 start|reload)
46 boot_mesg "Adding static routes..."
47
48 # First, initialize the table
49 init_table
50
51 # Add all routes
52 create_all_routes ${CONFIGFILE}
53
54 evaluate_retval
55 ;;
56
57 stop)
58 boot_mesg "Removing static routes..."
59 ip route flush table static >/dev/null 2>&1
60 evaluate_retval
61 ;;
62
63 *)
64 echo "Usage: ${0} {start|stop|reload}"
65 exit 1
66 ;;
67 esac