blob: dcc1206ff3361500607416de130952438b716bea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
ifup()
{
varname="\$${1}"
eval new_ifline=$varname
if [ "$new_ifline" = "dhcp" ]; then
# remove the .pid file if it exists
rm -f /etc/dhcpc/dhcpcd-${1}.{pid,cache} >/dev/null 2>&1
/usr/sbin/dhcpcd -t 10 -h $HOSTNAME $1
else
/sbin/ifconfig $new_ifline
fi
return $?
}
ifdown()
{
varname="\$${1}"
eval new_ifline=$varname
if [ "$new_ifline" = "dhcp" ]; then
/bin/kill `cat /etc/dhcpc/dhcpcd-${1}.pid`
else
/sbin/ifconfig $new_ifline down
fi
return $?
}
rtup()
{
varname="\$${1}"
eval new_rtline=$varname
/sbin/route add $new_rtline
return $?
}
rtdown()
{
varname="\$${1}"
eval new_rtline=$varname
/sbin/route del $new_rtline
return $?
}
case "$1" in
start)
if ! ck_daemon network; then
echo "Network is already running. Try 'network restart'"
exit
fi
stat_busy "Starting Network"
error=0
for ifline in ${INTERFACES[@]}; do
if echo $ifline | grep '^[^\!]' >/dev/null 2>&1; then
ifup $ifline || error=1
fi
done
for rtline in "${ROUTES[@]}"; do
if echo $rtline | grep '^[^\!]' 2>&1 >/dev/null; then
rtup $rtline || error=1
fi
done
if [ $error -eq 0 ]; then
add_daemon network
stat_done
else
stat_fail
fi
;;
stop)
if ck_daemon network; then
echo "Network is not running. Try 'network start'"
exit
fi
stat_busy "Stopping Network"
rm_daemon network
error=0
for rtline in "${ROUTES[@]}"; do
if echo $rtline | grep '^[^\!]' 2>&1 >/dev/null; then
rtdown $rtline || error=1
fi
done
for ifline in ${INTERFACES[@]}; do
if echo $ifline | grep '^[^\!]' 2>&1 >/dev/null; then
ifdown $ifline || error=1
fi
done
if [ $error -eq 0 ]; then
stat_done
else
stat_fail
fi
;;
restart)
$0 stop
sleep 2
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
esac
|