Changeset 3409
- Timestamp:
- 08/05/07 20:12:51 (1 year ago)
- Files:
-
- trunk/freewrt/package/broadcom-wl/Makefile (modified) (1 diff)
- trunk/freewrt/package/broadcom-wl/files/wl-broadcom (modified) (18 diffs)
- trunk/freewrt/package/fwifupdown/Makefile (modified) (1 diff)
- trunk/freewrt/package/fwifupdown/files/ifupdown.sh (modified) (2 diffs)
- trunk/freewrt/package/fwifupdown/files/main.sh (modified) (9 diffs)
- trunk/freewrt/package/fwifupdown/files/mfunctions.sh (modified) (3 diffs)
- trunk/freewrt/package/fwifupdown/lib/alias (modified) (1 diff)
- trunk/freewrt/package/fwifupdown/lib/bridge (modified) (6 diffs)
- trunk/freewrt/package/fwifupdown/lib/lladdr (modified) (2 diffs)
- trunk/freewrt/package/fwifupdown/lib/manual (added)
- trunk/freewrt/package/fwifupdown/lib/tuntap (modified) (5 diffs)
- trunk/freewrt/package/fwifupdown/lib/vlan (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/freewrt/package/broadcom-wl/Makefile
r3386 r3409 9 9 PKG_NAME:= broadcom-wl 10 10 PKG_VERSION:= 4.80.53.0 11 PKG_RELEASE:= 1 111 PKG_RELEASE:= 12 12 12 PKG_MD5SUM:= a7d8dde3ce474c361143b83e1d9890b1 13 13 PKG_MODULE:= 11 trunk/freewrt/package/broadcom-wl/files/wl-broadcom
r3386 r3409 7 7 # Copyright (c) 2007 8 8 # Thorsten Glaser <tg@freewrt.org> 9 # Christian Fischer <spaetzle@freewrt.org> 9 10 # Copyright (c) 2006 10 11 # Dirk Nehring <dnehring@freewrt.org> … … 20 21 21 22 iface_type() { 22 [ x"$IF_WIRELESS_TYPE" = x"broadcom"] && echo $IFACE | grep -q ^wl[0-9]23 [[ $IF_WIRELESS_TYPE = broadcom ]] && echo $IFACE | grep -q ^wl[0-9] 23 24 } 24 25 25 26 security_none() { 26 27 wsec=0 27 [ x"$IF_WIRELESS_MODE" = x"sta"] && init_debug wl join $IF_WIRELESS_SSID28 [[ $IF_WIRELESS_MODE = sta ]] && init_debug wl join $IF_WIRELESS_SSID 28 29 } 29 30 … … 35 36 init_debug wl wpa_auth 0 36 37 37 if [ x"$IF_WIRELESS_MODE" = x"sta"]; then38 if [[ $IF_WIRELESS_MODE = sta ]]; then 38 39 case $IF_WIRELESS_AUTHORIZATION in 39 shared)40 authorization=shared41 ;;42 *)43 authorization=open44 ;;40 shared) 41 authorization=shared 42 ;; 43 *) 44 authorization=open 45 ;; 45 46 esac 46 47 … … 51 52 for keyno in '' 0 1 2 3; do 52 53 eval wkey='$IF_WIRELESS_KEY'$keyno 53 test -z $wkey&& continue54 [[ -z $wkey ]] && continue 54 55 55 56 # wkey ist set, do an entry … … 58 59 59 60 # is key numberless? 60 test -z "$keyno"&& break # yes, ignore numbered keys61 [[ -z $keyno ]] && break # yes, ignore numbered keys 61 62 62 63 # primary key number set? 63 test -z "$pkey"&& pkey=$keyno # set it with the first one found64 [[ -z $pkey ]] && pkey=$keyno # set it with the first one found 64 65 65 66 # set primary key number from config if it isn't out of range 66 test x"$IF_WIRELESS_PRIMARY_KEY" = x"$keyno"&& pkey=$keyno67 [[ $IF_WIRELESS_PRIMARY_KEY = $keyno ]] && pkey=$keyno 67 68 done 68 69 69 test -z "$wkey_set"&& return 1 # no wepkey entries done, break here70 [[ -z $wkey_set ]] && return 1 # no wepkey entries done, break here 70 71 init_debug wl primary_key $pkey 71 72 fi … … 76 77 77 78 case $IF_WIRELESS_AUTHORIZATION in 78 psk)79 auth=480 ;; 81 psk2)82 auth=12883 ;; 84 "psk psk2")85 auth=13286 ;; 87 *)88 mstate 189 merr "Wrong wireless authorisation $IF_WIRELESS_AUTHORIZATION for security wpa-psk"90 return 179 psk) 80 auth=4 81 ;; 82 psk2) 83 auth=128 84 ;; 85 "psk psk2") 86 auth=132 87 ;; 88 *) 89 mstate 1 90 merr "Wrong wireless authorisation $IF_WIRELESS_AUTHORIZATION for security wpa-psk" 91 return 1 91 92 ;; 92 93 esac … … 97 98 # don't handle wds as special case, i think its only interesting 98 99 # if we have routed or bridged networking 99 if bridged_mode 100 then 100 if bridged_mode; then 101 101 cat > ${postup}/postup <<EOF 102 102 mprint -n "Starting nas daemon" … … 133 133 134 134 case $IF_WIRELESS_AUTHORIZATION in 135 wep)136 auth=0137 # only honour bridged or routed138 if bridged_mode; then139 cat > ${postup}/postup <<EOF135 wep) 136 auth=0 137 # only honour bridged or routed 138 if bridged_mode; then 139 cat > ${postup}/postup <<EOF 140 140 mprint -n "Starting nas daemon" 141 141 (doquit=0 … … 149 149 mstate 0 150 150 EOF 151 else152 mprint -n "Starting nas daemon"153 (doquit=0154 trap 'doquit=1' USR1155 while sleep 1; do156 [[ $doquit = 0 ]] || break157 /usr/sbin/nas -P /var/run/nas.lan.pid \158 -H 34954 -i $IFACE159 done) &160 echo $! >/var/run/nas.watch.pid161 mstate 0162 fi163 return 0164 ;; 165 wpa)166 auth=2167 ;; 168 wpa2)169 auth=64170 ;; 171 "wpa wpa2")172 auth=66173 ;; 174 *)175 merr "Wrong wireless authorisation $IF_WIRELESS_AUTHORIZATION for security wpa-psk"176 return 1151 else 152 mprint -n "Starting nas daemon" 153 (doquit=0 154 trap 'doquit=1' USR1 155 while sleep 1; do 156 [[ $doquit = 0 ]] || break 157 /usr/sbin/nas -P /var/run/nas.lan.pid \ 158 -H 34954 -i $IFACE 159 done) & 160 echo $! >/var/run/nas.watch.pid 161 mstate 0 162 fi 163 return 0 164 ;; 165 wpa) 166 auth=2 167 ;; 168 wpa2) 169 auth=64 170 ;; 171 "wpa wpa2") 172 auth=66 173 ;; 174 *) 175 merr "Wrong wireless authorisation $IF_WIRELESS_AUTHORIZATION for security wpa-psk" 176 return 1 177 177 ;; 178 178 esac … … 181 181 init_debug wl eap 0 182 182 183 if bridged_mode 184 then 183 if bridged_mode; then 185 184 cat > ${postup}/postup <<EOF 186 185 mprint -n "Starting nas daemon" … … 215 214 216 215 get_bridge_iface() { 217 [ -x "$(which brctl)"] || return 1216 [[ -x $(whence -p brctl) ]] || return 1 218 217 brctl show 2>&- | grep -q $IFACE || return 1 219 for var in $(brctl show 2>&- | grep -o ^[a-z]*[^[:space:]]) 220 do 218 for var in $(brctl show 2>&- | grep -o ^[a-z]*[^[:space:]]); do 221 219 brctl showstp $var | grep -q ^${IFACE}[[:space:]] || continue 222 220 BRIDGE_IFACE=$var … … 226 224 227 225 bridged_mode() { 228 if [ x"$PARENT_IFACE_TYPE" = x"bridge" ] 229 then 226 if [[ $PARENT_IFACE_TYPE = bridge ]]; then 230 227 BRIDGE_IFACE=$PARENT_IFACE 231 228 else 232 229 get_bridge_iface || return 1 233 230 234 if ! is_up $BRIDGE_IFACE 235 then 231 if ! is_up $BRIDGE_IFACE; then 236 232 mprint -n "Starting nas daemon" 237 233 mstate 1 … … 240 236 fi 241 237 fi 242 postup="/tmp/ifupdown/pcode/${BRIDGE_IFACE}/$ {IFACE}"238 postup="/tmp/ifupdown/pcode/${BRIDGE_IFACE}/$IFACE" 243 239 mkdir -p $postup 244 240 chmod 700 $postup … … 259 255 mprint -n "Initializing $IFACE_TYPE $IFACE" 260 256 261 [ -z "$IF_WIRELESS_SSID"] && err="ESSID not set"262 [ -z "$IF_WIRELESS_MODE"] && err="Operation mode not set"263 [ x"$IF_WIRELESS_SECURITY" = x"8021x" -a -z "$IF_WIRELESS_RADIUS_IPADDR"\264 -a x"$IF_WIRELESS_AUTHORIZATION" != x"wep"] && \257 [[ -z $IF_WIRELESS_SSID ]] && err="ESSID not set" 258 [[ -z $IF_WIRELESS_MODE ]] && err="Operation mode not set" 259 [[ $IF_WIRELESS_SECURITY = 8021x && -z $IF_WIRELESS_RADIUS_IPADDR &&\ 260 $IF_WIRELESS_AUTHORIZATION != wep ]] && \ 265 261 err="Radius server address not set" 266 262 267 [ -n "$err" ] && {263 if [[ -n $err ]]; then 268 264 mstate 1 269 265 merr $err 270 266 return 1 271 }267 fi 272 268 273 269 … … 306 302 ;; 307 303 wds) 308 [ -z "$IF_WIRELESS_WDS"] && return 1304 [[ -z $IF_WIRELESS_WDS ]] && return 1 309 305 # TODO: messages 310 306 init_debug wl ap 1 … … 327 323 328 324 case $IF_WIRELESS_ENCRYPTION in 329 wep)330 wsec=1331 ;;332 tkip)333 wsec=2334 ;;335 aes)336 wsec=4337 ;;338 aes+tkip)339 wsec=6340 ;;325 wep) 326 wsec=1 327 ;; 328 tkip) 329 wsec=2 330 ;; 331 aes) 332 wsec=4 333 ;; 334 aes+tkip) 335 wsec=6 336 ;; 341 337 esac 342 338 343 339 # set country 344 [ -n "$IF_WIRELESS_COUNTRY"] && init_debug wl country $IF_WIRELESS_COUNTRY340 [[ -n $IF_WIRELESS_COUNTRY ]] && init_debug wl country $IF_WIRELESS_COUNTRY 345 341 346 342 # set gmode 347 [ -n "$IF_WIRELESS_GMODE"] && init_debug wl gmode $IF_WIRELESS_GMODE343 [[ -n $IF_WIRELESS_GMODE ]] && init_debug wl gmode $IF_WIRELESS_GMODE 348 344 349 345 # set isolate mode 350 [ -n "$IF_WIRELESS_ISOLATE"] && init_debug wl ap_isolate \346 [[ -n $IF_WIRELESS_ISOLATE ]] && init_debug wl ap_isolate \ 351 347 $IF_WIRELESS_ISOLATE 352 348 353 349 # set macmode mode 354 [ -n "$IF_WIRELESS_MACMODE"] && init_debug wl macmode $IF_WIRELESS_MACMODE350 [[ -n $IF_WIRELESS_MACMODE ]] && init_debug wl macmode $IF_WIRELESS_MACMODE 355 351 356 352 # set MAC addresses 357 [ -n "$IF_WIRELESS_MAC"] && init_debug wl mac $IF_WIRELESS_MAC353 [[ -n $IF_WIRELESS_MAC ]] && init_debug wl mac $IF_WIRELESS_MAC 358 354 359 355 # set WLAN channel 360 [ -n "$IF_WIRELESS_CHANNEL"] && init_debug wl channel $IF_WIRELESS_CHANNEL356 [[ -n $IF_WIRELESS_CHANNEL ]] && init_debug wl channel $IF_WIRELESS_CHANNEL 361 357 362 358 # set frameburst 363 [ -n "$IF_WIRELESS_FRAMEBURST"] && init_debug wl frameburst \359 [[ -n $IF_WIRELESS_FRAMEBURST ]] && init_debug wl frameburst \ 364 360 $IF_WIRELESS_FRAMEBURST 365 361 366 362 # set afterburner 367 363 # remove this because command afterburner_override seems to be nonexistent for now 368 #[ -n "$IF_WIRELESS_AFTERBURNER"] && init_debug wl afterburner_override \364 #[[ -n $IF_WIRELESS_AFTERBURNER ]] && init_debug wl afterburner_override \ 369 365 # $IF_WIRELESS_AFTERBURNER 370 366 … … 373 369 374 370 case $IF_WIRELESS_SECURITY in 375 none)376 security_none377 ;;378 wep)379 security_wep380 ;;381 wpa-psk)382 security_wpapsk383 ;;384 8021x)385 security_8021x386 ;;387 *)388 # no fallback389 mstate 1390 merr "Wireless security not set"391 return 1392 ;;371 none) 372 security_none 373 ;; 374 wep) 375 security_wep 376 ;; 377 wpa-psk) 378 security_wpapsk 379 ;; 380 8021x) 381 security_8021x 382 ;; 383 *) 384 # no fallback 385 mstate 1 386 merr "Wireless security not set" 387 return 1 388 ;; 393 389 esac 394 390 … … 398 394 mstate 0 399 395 400 [ -z "$PARENT_IFACE_TYPE"] && is_up ${BRIDGE_IFACE:="FOO"} || return 0401 402 [ -f /tmp/ifupdown/pcode/${BRIDGE_IFACE}/${IFACE}/postup] && \396 [[ -z $PARENT_IFACE_TYPE ]] && is_up ${BRIDGE_IFACE:="FOO"} || return 0 397 398 [[ -f /tmp/ifupdown/pcode/${BRIDGE_IFACE}/${IFACE}/postup ]] && \ 403 399 . /tmp/ifupdown/pcode/${BRIDGE_IFACE}/${IFACE}/postup 404 400 } trunk/freewrt/package/fwifupdown/Makefile
r3239 r3409 41 41 cd ${IDIR_FWIFUPDOWN}/sbin && ln -s ifup ifdown 42 42 ${INSTALL_DATA} ${PKG_SRC_ROOT}/lib/lladdr ${IDIR_FWIFUPDOWN}/${PKG_CONFIG_PLUGDIR}/ 43 ${INSTALL_DATA} ${PKG_SRC_ROOT}/lib/manual ${IDIR_FWIFUPDOWN}/${PKG_CONFIG_METHSDIR} 43 44 44 45 ifeq (${FWIFUPDOWN_CONFIG_BRIDGE},y) trunk/freewrt/package/fwifupdown/files/ifupdown.sh
r3105 r3409 10 10 11 11 config() { 12 [ x"$1" = x"1"]12 [[ $1 = 1 ]] 13 13 } 14 14 … … 34 34 redirect= 35 35 fi 36 [ -e /tmp/.booting] && redirect="$redirect >/dev/console"36 [[ -e /tmp/.booting ]] && redirect="$redirect >/dev/console" 37 37 38 38 # cleanup ifstate files trunk/freewrt/package/fwifupdown/files/main.sh
r3198 r3409 8 8 # 9 9 10 built_in() { 11 local what=$1 12 local alias=$(alias $what) 13 unalias $what 14 alias $(echo $alias|sed 's/'\''//g') 15 shift 16 $what $@ 17 } 18 19 config() { 20 [ x"$1" != x"0" ] 21 } 22 23 __ifupdown() { 10 main_ifupdown() { 24 11 local environ=$(cat $ENVFILE) 25 12 … … 31 18 32 19 retval=$? 33 echo $environ > $ENVFILE 20 grep -q RT_BB_NOEXEC=1 $ENVFILE && retval=0 21 echo $environ >$ENVFILE 34 22 return $retval 35 23 } 36 24 37 __exit() {38 [ x"$1" != x"0" ] && echo "RT_ERR=1" >>$ENVFILE25 main_exit() { 26 [[ $1 != 0 ]] && echo "RT_ERR=1" >>$ENVFILE 39 27 exit $1 40 }41 42 iface_exists() {43 grep -q "${1:-$IFACE}:" /proc/net/dev44 }45 46 is_up() {47 local iface=${1:-$IFACE}48 49 if iface_exists $iface50 then51 ip a|grep ${iface}:[[:space:]]|grep -q UP && return52 53 ### ifupdown netlink bug workaround ###54 # suppress "ip: RTNETLINK answers: File exists" message in the case of55 # iface is down but an ip address is assigned56 ip a|grep ${iface}$|grep -q inet && ip addr flush dev $iface >/dev/null 2>&157 ### end workaround ###58 fi59 return 160 28 } 61 29 … … 67 35 68 36 # create env file 69 if ! [ -f "$ENVFILE" ] 70 then 71 [ -d ${ENVFILE%/*} ] || mkdir -p ${ENVFILE%/*} 37 if ! [[ -f $ENVFILE ]]; then 38 [[ -d ${ENVFILE%/*} ]] || mkdir -p ${ENVFILE%/*} 72 39 echo "MDENT=0" >> $ENVFILE 73 40 echo "LASTLOG=0" >> $ENVFILE 74 41 75 is_up && IFACE_STATE="up" || IFACE_STATE="down" 76 echo "IFACE_STATE=$IFACE_STATE" >> $ENVFILE 77 78 if [ x"$IFACE" != x"lo" ] 79 then 42 is_up && IFACE_STATE=up || IFACE_STATE=down 43 echo "IFACE_STATE=$IFACE_STATE" >>$ENVFILE 44 45 if [[ $IFACE != lo ]]; then 80 46 # search for existing lib files end evaluate iface type by using the appropriate 81 47 # function from lib file 82 for lib in ${LIBDIR}/iftypes/* 83 do 84 [ -f $lib ] && (. $lib; iface_type 2>&-) || continue 85 if [ -n "$lastmatch" ] 86 then 87 if [ ${lib##*/} = ${lastmatch##*/} ] 88 then 48 for lib in ${LIBDIR}/iftypes/*; do 49 [[ -f $lib ]] && (. $lib; iface_type 2>&-) || continue 50 if [[ -n $lastmatch ]]; then 51 if [[ ${lib##*/} = ${lastmatch##*/} ]]; then 89 52 mprint -s "Warning: $lib overlays $lastmatch" 90 53 else … … 97 60 98 61 # if iface type isn't evaluated type "iface" is default 99 [ -n "$lastmatch" ] && IFACE_TYPE=${lastmatch##*/} || IFACE_TYPE="iface"62 [[ -n $lastmatch ]] && IFACE_TYPE=${lastmatch##*/} || IFACE_TYPE=iface 100 63 101 64 # update env 102 echo "IFACE_TYPE=$ {IFACE_TYPE}" >>$ENVFILE65 echo "IFACE_TYPE=$IFACE_TYPE" >>$ENVFILE 103 66 fi 104 67 … … 111 74 done 112 75 113 [ $t_mdent -gt $MDENT] && MDENT=$t_mdent76 [[ $t_mdent -gt $MDENT ]] && MDENT=$t_mdent 114 77 main_pos_update 115 78 } 116 79 117 80 main_pos_update() { 118 [ x"$MDENT" = x"0" ] && STARTCOL= || STARTCOL="[$(expr ${MDENT:-0} \* ${TAB})C" 81 [[ $MDENT = 0 ]] && STARTCOL= || \ 82 STARTCOL="[$(( ${MDENT:-0} * $TAB))C" 119 83 sed 's/MDENT=[0-9]*/'MDENT=$MDENT'/' -i $ENVFILE 120 84 } 121 85 86 ### global helper functions ### 87 88 config() { 89 [[ $1 != 0 ]] 90 } 91 92 iface_exists() { 93 grep -q "${1:-$IFACE}:" /proc/net/dev 94 } 95 96 phys_exist() { 97 config $IFACE_LOGICAL && return 98 iface_exists && return 99 merr "No such device" 100 return 1 101 } 102 103 is_up() { 104 local iface=${1:-$IFACE} 105 106 iface_exists $iface || return 1 107 ip a|grep ${iface}:[[:space:]]|grep -q UP && return 108 109 ### ifupdown netlink bug workaround ### 110 # suppress "ip: RTNETLINK answers: File exists" message in the case of 111 # iface is down but an ip address is assigned 112 ip a|grep ${iface}$|grep -q inet && ip addr flush dev $iface >/dev/null 2>&1 113 ### end workaround ### 114 115 return 1 116 } 117 118 ### functions used by main up/down functions ### 119 ### DON'T remove empty ones ### 120 121 main_exec_hookscripts() { 122 for hook in ${LIBDIR}/${1}/${2}; do 123 [[ -f $hook ]] || continue 124 . $hook 125 eval "${hook##*/}_$3" || [[ $? = 127 ]] || exit 126 done 127 } 128 129 main_bb_methods_override() { 130 [[ -r ${LIBDIR}/methods/$METHOD ]] || return 131 . ${LIBDIR}/methods/$METHOD 132 whence ${METHOD}_$1 2>&- 1>&- || return 133 134 # fake busybox ifupdown.c up or down code 135 case $1 in 136 up) 137 eval $IF_PRE_UP 138 eval ${METHOD}_$1 || exit 139 eval $IF_UP 140 # call up function from here because we leave 141 # run-parts after returning 142 main_up 143 ;; 144 down) 145 eval $IF_DOWN 146 eval ${METHOD}_$1 || exit 147 eval $IF_POST_DOWN 148 main_postdown 149 ;; 150 esac 151 152 RT_BB_NOEXEC=1 153 } 154 155 main_exec_pcode() { 156 [[ -d /tmp/ifupdown/pcode/$IFACE ]] || return 157 for dir in /tmp/ifupdown/pcode/${IFACE}/*; do 158 [[ -f ${dir}/$1 ]] || continue 159 . ${dir}/$1 160 done 161 } 162 163 prereq_preup() { 164 main_prereq_preup 165 } 166 167 main_prereq_preup() { 168 is_up || return 0 169 mup 170 mstate 1 171 minfo "Interface already up" 172 exit 1 173 } 174 175 prereq_up() { 176 main_prereq_up 177 } 178 179 main_prereq_up() { 180 is_up 181 mstate $? || exit 182 } 183 184 prereq_down() { 185 : 186 } 187 188 prereq_postdown() { 189 main_prereq_postdown 190 } 191 192 main_prereq_postdown() { 193 is_up 194 mstate $((!$?)) || exit 195 [[ $IFACE_STATE = down ]] && minfo "Interface already down" 196 return 0 197 } 198 199 if_preup() { 200 : 201 } 202 203 if_up() { 204 : 205 } 206 207 if_down() { 208 : 209 } 210 211 if_postdown() { 212 : 213 } 214 215 ### main up/down functions ### 216 122 217 main_preup() { 123 config $RT_PREUP_PRINTING_OFF || mstart 124 125 if ! config $RT_PREUP_IFUP_CHECK_OFF && is_up 126 then 127 if ! config $RT_PREUP_PRINTING_OFF 128 then 129 mup 130 mstate 1 131 minfo "Interface already up" 132 fi 133 exit 1 134 fi 135 136 if_preup 2>&- 137 retval=$? 138 139 [ x"$retval" != x"0" -a x"$retval" != x"127" ] && { 140 fail_preup 2>&- || exit 1 141 } 142 143 config $RT_PREUP_PRINTING_OFF && return 218 # print start message 219 mstart 220 221 # break if device is physical and not exist 222 phys_exist || exit 223 224 # check iface state and print state message 225 # break if iface is already up 226 prereq_preup || exit 227 228 # execute "pre busybox up" function 229 # sourced from appropriate iftype script 230 if_preup || fail_preup || exit 231 232 # print "going up" message 144 233 mup 234 235 # execute plugins 236 main_exec_hookscripts plugins '*' preup 237 238 # execute method preup function if present 239 main_exec_hookscripts methods $METHOD preup 240 241 # override busybox ifupdown.c method if function present 242 main_bb_methods_override up 243 244 # bypass execution of further busybox ifupdown.c code 245 config $RT_BB_NOEXEC || return 0 246 echo RT_BB_NOEXEC=1 >>$ENVFILE 247 builtin exit 1 145 248 } 146 249 147 250 main_up() { 148 [ x"$METHOD" = x"manual" ] && ip link set up dev $IFACE 149 150 if ! config $RT_UP_IFUP_CHECK_OFF 151 then 152 is_up 153 retval=$? 154 config $RT_UP_PRINTING_OFF || mstate $retval 155 [ x"$retval" != x"0" ] && exit 1 156 fi 157 158 if_up 2>&- 159 retval=$? 160 161 [ x"$retval" != x"0" -a x"$retval" != x"127" ] && { 162 fail_up 2>&- || exit 1 163 } 164 165 if [ -d /tmp/ifupdown/pcode/${IFACE} ] 166 then 167 for dir in /tmp/ifupdown/pcode/${IFACE}/* 168 do 169 [ -f ${dir}/postup ] || continue 170 . ${dir}/postup 171 done 172 fi 251 # execute method postup function if present 252 main_exec_hookscripts methods $METHOD postup 253 254 # execute plugins 255 main_exec_hookscripts plugins '*' up 256 257 # check iface state and print state message 258 # break if iface isn't up 259 prereq_up || exit 260 261 # execute "post busybox up" function 262 # sourced from appropriate iftype script 263 if_up || fail_up || exit 264 265 # execute postcode if present 266 main_exec_pcode postup 173 267 } 174 268 175 269 main_down() { 176 config $RT_DOWN_PRINTING_OFF || mstop 177 178 if [ -d /tmp/ifupdown/pcode/${IFACE} ] 179 then 180 for dir in /tmp/ifupdown/pcode/${IFACE}/* 181 do 182 [ -f ${dir}/predown ] || continue 183 . ${dir}/predown 184 done 185 fi 186 187 if_down 2>&- 188 retval=$? 189 190 [ x"$retval" != x"0" -a x"$retval" != x"127" ] && { 191 fail_down 2>&- || exit 1 192 } 193 194 config $RT_DOWN_PRINTING_OFF && return 270 # print stop message 271 mstop 272 273 # break if device is physical and not exist 274 phys_exist || exit 275 276 # nothing predefined 277 prereq_down || exit 278 279 # execute postcode if present 280 main_exec_pcode predown 281 282 # execute "pre busybox down" function 283 # sourced from appropriate iftype script 284 if_down || fail_down || exit 285 286 # print "going down" message 195 287 mdown 288 289 # execute plugins 290 main_exec_hookscripts plugins '*' down 291 292 # execute method predown function if present 293 main_exec_hookscripts methods $METHOD predown 294 295 # override busybox ifupdown.c method if userspace function present 296 main_bb_methods_override down 297 298 # bypass execution of further busybox ifupdown.c code 299 config $RT_BB_NOEXEC || return 0 300 echo RT_BB_NOEXEC=1 >>$ENVFILE 301 builtin exit 1 196 302 } 197 303 198 304 main_postdown() { 199 [ x"$METHOD" = x"manual" ] && { 200 ip addr flush dev $IFACE 201 ip link set down dev $IFACE 202 } 203 204 if ! config $RT_POSTDOWN_IFDOWN_CHECK_OFF 205 then 206 if [ $IFACE_STATE = "down" ] 207 then 208 if ! config $RT_POSTDOWN_PRINTING_OFF 209 then 210 mdown 211 mstate 1 212 minfo "Interface already down" 213 fi 214 else 215 is_up && retval=1 || retval=0 216 config $RT_POSTDOWN_PRINTING_OFF || mstate $retval 217 [ "$retval" != "0" ] && exit 1 218 fi 219 fi 220 221 if_postdown 2>&- 222 retval=$? 223 224 [ x"$retval" != x"0" -a x"$retval" != x"127" ] && { 225 fail_postdown 2>&- || exit 1 226 } 305 # execute method postdown function if present 306 main_exec_hookscripts methods $METHOD postdown 307 308 # execute plugins 309 main_exec_hookscripts plugins '*' postdown 310 311 # check iface state and print state message 312 # break if iface isn't down 313 prereq_postdown || exit 314 315 # execute "post busybox down" function 316 # sourced from appropriate iftype script 317 if_postdown || fail_postdown || exit 227 318 228 319 # pcode cleanup 229 320 rm -rf /tmp/ifupdown/pcode/*/$IFACE 2>&- 1>&- 230 }231 232 main_exec_dirhooks() {233 for hook in ${LIBDIR}/${1}/${2}234 do235 [ -f $hook ] || continue236 . $hook237 eval $3 2>&-238 retval=$?239 [ x"$retval" != x"0" -a x"$retval" != x"127" ] && exit 1240 return241 done242 }243 244 main_exec_plugins() {245 for plugin in ${LIBDIR}/plugins/*; do246 [ -f $plugin ] || continue247 . $plugin248 eval "${plugin##*/}_${1}" 2>&-249 retval=$?250 [ x"$retval" != x"0" -a x"$retval" != x"127" ] && exit 1251 done252 }253 254 main_exec_inlinehooks() {255 case $SUBMODE in256 if-pre-up)257 [ -n "$IF_PRE_UP" ] && eval $IF_PRE_UP258 ;;259 if-up)260 [ -n "$IF_UP" ] && eval $IF_UP261 ;;262 if-down)263 [ -n "$IF_DOWN" ] && eval $IF_DOWN264 ;;265 if-post-down)266 [ -n "$IF_POST_DOWN" ] && eval $IF_POST_DOWN267 ;;268 esac269 321 } 270 322 … … 280 332 config $FWIFUPDOWN_DEBUG && set -x 281 333 282 RT_PREUP_PRINTING_OFF=0283 RT_UP_PRINTING_OFF=0284 RT_DOWN_PRINTING_OFF=0285 RT_POSTDOWN_PRINTING_OFF=0286 RT_PREUP_IFUP_CHECK_OFF=0287 RT_UP_IFUP_CHECK_OFF=0288 RT_POSTDOWN_IFDOWN_CHECK_OFF=0289 334 RT_BB_NOEXEC=0 290 335 RT_ERR=0 … … 293 338 IFACE_TYPE="none" 294 339 295 alias exit="__exit" 296 alias ifup="__ifupdown ifup" 297 alias ifdown="__ifupdown ifdown" 298 [ -z "$KSH_VERSION" ] || alias which='whence -p' 299 300 if ! [ -f /etc/network/mfunctions.sh ] 301 then 340 alias exit="main_exit" 341 alias ifup="main_ifupdown ifup" 342 alias ifdown="main_ifupdown ifdown" 343 344 if [[ ! -f /etc/network/mfunctions.sh ]]; then 302 345 logger -t ifupdown "/etc/network/mfunctions.sh not found" 303 346 exit 1 … … 307 350 main_env_update 308 351 309 config $RT_ERR && built_in exit 1 310 311 if [ x"$IFACE_TYPE" != x"iface" ] 312 then 313 if [ -f "${LIBDIR}/iftypes/${IFACE_TYPE}" ] 314 then 352 config $RT_ERR && builtin exit 1 353 354 if [[ $IFACE_TYPE != iface ]]; then 355 if [[ -f ${LIBDIR}/iftypes/$IFACE_TYPE ]]; then 315 356 . ${LIBDIR}/iftypes/$IFACE_TYPE 316 357 else
