updated on Tue Jan 17 16:10:12 UTC 2012
[aur-mirror.git] / networkmod / hooks.patch
blob39c8ca5e1e6e3bbc4b455f7d92a7b6b4d07395b9
1 --- network.orig
2 +++ network
3 @@ -12,6 +12,15 @@
4 # dhcpcd settings
5 [ -f /etc/conf.d/dhcpcd ] && . /etc/conf.d/dhcpcd
8 +function run_hooks ()
9 +{
10 + nwm_confdir="/etc/networkmod/$1"
11 + if [ -d "$nwm_confdir" ]; then
12 + find "$nwm_confdir" -type f -executable -exec {} "$2" \;
13 + fi
16 ifup()
18 if [ "$1" = "" ]; then
19 @@ -29,6 +38,8 @@
20 ifname=${ifcfg%% *}
23 + run_hooks pre-ifup "$ifname"
25 /sbin/ifconfig $ifname up
27 wi_up $1 || return 1
28 @@ -41,6 +52,9 @@
29 else
30 /sbin/ifconfig $ifcfg
33 + run_hooks post-ifup "$ifname"
35 return $?
38 @@ -49,6 +63,8 @@
39 eval iwcfg="\$wlan_${1}"
40 [ "$iwcfg" = "" ] && return 0
42 + run_hooks pre-wi_up "$1"
44 /usr/sbin/iwconfig $iwcfg
45 [[ -z "$WIRELESS_TIMEOUT" ]] && WIRELESS_TIMEOUT=2
46 sleep $WIRELESS_TIMEOUT
47 @@ -58,6 +74,9 @@
48 printhl "Could not associate $1 - try increasing WIRELESS_TIMEOUT and check network is WEP or has no security"
49 return 1
52 + run_hooks post-wi_up "$1"
54 return 0
57 @@ -73,8 +92,15 @@
58 /bin/kill $(cat /var/run/dhcpcd-${1}.pid)
63 + run_hooks pre-ifdown "$1"
65 # Always bring the interface itself down
66 /sbin/ifconfig ${1} down >/dev/null 2>&1
68 + run_hooks post-ifdown "$1"
70 return $?
73 @@ -98,11 +124,17 @@
74 return 1
76 eval routecfg="\$${1}"
78 + run_hooks pre-rtup "$1"
80 if grep -q :: <<< $routecfg; then
81 /sbin/route -A inet6 add $routecfg
82 else
83 /sbin/route add $routecfg
86 + run_hooks post-rtup "$1"
88 return $?
91 @@ -113,11 +145,17 @@
92 return 1
94 eval routecfg="\$${1}"
96 + run_hooks pre-rtdown "$1"
98 if grep -q :: <<< $routecfg; then
99 /sbin/route -A inet6 del $routecfg
100 else
101 /sbin/route del $routecfg
104 + run_hooks post-rtdown "$1"
106 return $?
109 @@ -136,6 +174,7 @@
111 bond_up()
113 + run_hooks pre-bond_up ""
114 for ifline in ${BOND_INTERFACES[@]}; do
115 if [ "$ifline" = "${ifline#!}" ]; then
116 eval bondcfg="\$bond_${ifline}"
117 @@ -144,20 +183,24 @@
120 done
121 + run_hooks post-bond_up ""
124 bond_down()
126 + run_hooks pre-bond_down ""
127 for ifline in ${BOND_INTERFACES[@]}; do
128 if [ "$ifline" = "${ifline#!}" ]; then
129 eval bondcfg="\$bond_${ifline}"
130 /sbin/ifenslave -d $ifline $bondcfg || error=1
132 done
133 + run_hooks post-bond_down ""
136 bridge_up()
138 + run_hooks pre-bridge_up ""
139 for br in ${BRIDGE_INTERFACES[@]}; do
140 if [ "$br" = "${br#!}" ]; then
141 # if the bridge already exists, remove it
142 @@ -183,26 +226,29 @@
143 done
145 done
146 + run_hooks post-bridge_up ""
149 bridge_down()
151 + run_hooks pre-bridge_down ""
152 for br in ${BRIDGE_INTERFACES[@]}; do
153 if [ "$br" = "${br#!}" ]; then
154 /usr/sbin/brctl delbr $br
156 done
157 + run_hooks post-bridge_down ""
161 case "$1" in
162 start)
163 - if ! ck_daemon network; then
164 - echo "Network is already running. Try 'network restart'"
165 + if ! ck_daemon networkmod; then
166 + echo "Networkmod is already running. Try 'networkmod restart'"
167 exit
170 - stat_busy "Starting Network"
171 + stat_busy "Starting Networkmod"
172 error=0
173 # bring up bridge interfaces
174 bridge_up
175 @@ -221,25 +267,25 @@
177 done
178 if [ $error -eq 0 ]; then
179 - add_daemon network
180 + add_daemon networkmod
181 stat_done
182 else
183 stat_fail
186 stop)
187 - #if ck_daemon network; then
188 - # echo "Network is not running. Try 'network start'"
189 + #if ck_daemon networkmod; then
190 + # echo "Networkmod is not running. Try 'networkmod start'"
191 # exit
194 if [ "${NETWORK_PERSIST}" = "yes" -o "${NETWORK_PERSIST}" = "YES" ]; then
195 - status "Skipping Network Shutdown" true
196 + status "Skipping Networkmod Shutdown" true
197 exit 0
200 - stat_busy "Stopping Network"
201 - rm_daemon network
202 + stat_busy "Stopping Networkmod"
203 + rm_daemon networkmod
204 error=0
205 for rtline in "${ROUTES[@]}"; do
206 if [ "$rtline" = "${rtline#!}" ]; then
207 @@ -270,7 +316,7 @@
208 $1 $2
211 - echo "usage: $0 {start|stop|restart}"
212 + echo "usage: $0 {start|stop|restart}"
213 echo " $0 {ifup|ifdown|iflist|rtup|rtdown|rtlist}"
214 esac