7 [ -f /etc
/conf.d
/wireless
] && .
/etc
/conf.d
/wireless
8 # ethernet bonding settings
9 [ -f /etc
/conf.d
/bonding
] && .
/etc
/conf.d
/bonding
11 [ -f /etc
/conf.d
/bridges
] && .
/etc
/conf.d
/bridges
13 [ -f /etc
/conf.d
/dhcpcd
] && .
/etc
/conf.d
/dhcpcd
17 if [ "$1" = "" ]; then
18 echo "usage: $0 ifup <interface_name>"
25 if [ "$ifcfg" = "dhcp" ]; then
26 # remove the .pid file if it exists
27 /bin
/rm -f /var
/run
/dhcpcd-
${1}.pid
>/dev
/null
2>&1
28 /bin
/rm -f /var
/run
/dhcpcd-
${1}.cache
>/dev
/null
2>&1
29 /sbin
/dhcpcd
$DHCPCD_ARGS ${1}
33 if grep -q " ${1}:" <<< `/usr/sbin/ip a`; then
34 /usr
/sbin
/ip link
set $1 up
44 eval iwcfg
="\$wlan_${1}"
45 [ "$iwcfg" = "" ] && return 0
47 /usr
/sbin
/iwconfig
$iwcfg
48 [[ -z "$WIRELESS_TIMEOUT" ]] && WIRELESS_TIMEOUT
=2
49 sleep $WIRELESS_TIMEOUT
51 bssid
=`iwgetid $1 -ra`
52 if [[ "$bssid" = "00:00:00:00:00:00" ]]; then
53 printhl
"Could not associate $1 - try increasing WIRELESS_TIMEOUT and check network is WEP or has no security"
61 if [ "$1" = "" ]; then
62 echo "usage: $0 ifdown <interface_name>"
66 if [ "$ifcfg" = "dhcp" ]; then
67 if [ -f /var
/run
/dhcpcd-
${1}.pid
]; then
68 /bin
/kill $
(cat /var
/run
/dhcpcd-
${1}.pid
)
71 if grep -q " ${1}:" <<< `/usr/sbin/ip a`; then
72 /usr
/sbin
/ip addr flush
$1
75 # Always bring the interface itself down
76 if grep -q " ${1}:" <<< `/usr/sbin/ip a`; then
77 /usr
/sbin
/ip link
set $1 down
84 for ifline
in ${INTERFACES[@]}; do
85 if [ "$ifline" = "${ifline#!}" ]; then
90 eval real_ifline
=\$
${ifline#!}
97 if [ "$1" = "" ]; then
98 echo "usage: $0 rtup <route_name>"
101 eval routecfg
="\$${1}"
102 /usr
/sbin
/ip route add
$routecfg
108 if [ "$1" = "" ]; then
109 echo "usage: $0 rtdown <route_name>"
112 eval routecfg
="\$${1}"
114 /usr
/sbin
/ip route del
$routecfg
120 for rtline
in ${ROUTES[@]}; do
121 if [ "$rtline" = "${rtline#!}" ]; then
126 eval real_rtline
=\$
${rtline#!}
133 for ifline
in ${BOND_INTERFACES[@]}; do
134 if [ "$ifline" = "${ifline#!}" ]; then
135 eval bondcfg
="\$bond_${ifline}"
136 if [ -n "${bondcfg}" ]; then
137 /sbin
/ifenslave
$ifline $bondcfg || error
=1
145 for ifline
in ${BOND_INTERFACES[@]}; do
146 if [ "$ifline" = "${ifline#!}" ]; then
147 eval bondcfg
="\$bond_${ifline}"
148 /sbin
/ifenslave
-d $ifline $bondcfg || error
=1
155 for br
in ${BRIDGE_INTERFACES[@]}; do
156 if [ "$br" = "${br#!}" ]; then
157 # if the bridge already exists, remove it
158 if [ "$(/sbin/ifconfig $br 2>/dev/null)" ]; then
159 /usr
/sbin
/ip link
set $br down
160 /usr
/sbin
/brctl delbr
$br
162 /usr
/sbin
/brctl addbr
$br
163 eval brifs
="\$bridge_${br}"
164 for brif
in $brifs; do
165 if [ "$brif" = "${brif#!}" ]; then
166 for ifline
in ${BOND_INTERFACES[@]}; do
167 if [ "$brif" = "$ifline" ] && [ "$ifline" = "${ifline#!}" ]; then
169 eval bondcfg
="\$bond_${ifline}"
170 /sbin
/ifenslave
$ifline $bondcfg || error
=1
175 /usr
/sbin
/brctl addif
$br $brif || error
=1
179 /usr
/sbin
/brctl setfd
$br 1
180 /usr
/sbin
/brctl stp
$br off
181 /usr
/sbin
/brctl sethello
$br 1
188 for br
in ${BRIDGE_INTERFACES[@]}; do
189 if [ "$br" = "${br#!}" ]; then
190 /usr
/sbin
/brctl delbr
$br
198 if ! ck_daemon network
; then
199 echo "Network is already running. Try 'network restart'"
203 stat_busy
"Starting Network with IP"
205 # bring up bridge interfaces
207 # bring up ethernet interfaces
208 for ifline
in ${INTERFACES[@]}; do
209 if [ "$ifline" = "${ifline#!}" ]; then
210 ifup
$ifline || error
=1
213 # bring up bond interfaces
216 for rtline
in "${ROUTES[@]}"; do
217 if [ "$rtline" = "${rtline#!}" ]; then
218 rtup
$rtline || error
=1
221 if [ $error -eq 0 ]; then
222 add_daemon network-ip
229 #if ck_daemon network; then
230 # echo "Network is not running. Try 'network start'"
234 stat_busy
"Stopping Network with IP"
237 for rtline
in "${ROUTES[@]}"; do
238 if [ "$rtline" = "${rtline#!}" ]; then
239 rtdown
$rtline || error
=1
242 # bring down bond interfaces
244 for ifline
in ${INTERFACES[@]}; do
245 if [ "$ifline" = "${ifline#!}" ]; then
246 ifdown
$ifline || error
=1
249 # bring down bridge interfaces
251 if [ $error -eq 0 ]; then
262 ifup|ifdown|iflist|rtup|rtdown|rtlist
)
266 echo "usage: $0 {start|stop|restart}"
267 echo " $0 {ifup|ifdown|iflist|rtup|rtdown|rtlist}"
270 # vim: set ts=2 noet: