Changeset cb45bc1 in freewrt
- Timestamp:
- Jun 26, 2007, 8:47:14 PM (18 years ago)
- Children:
- b7c164d
- Parents:
- 34bf5b5
- Location:
- package/fwifupdown/files
- Files:
-
- 2 edited
-
ifupdown.sh (modified) (1 diff)
-
main.sh (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
package/fwifupdown/files/ifupdown.sh
r34bf5b5 rcb45bc1 8 8 # 9 9 10 what=$ (basename $0)10 what=${0##*/} 11 11 case $what in 12 12 ifup) -
package/fwifupdown/files/main.sh
r34bf5b5 rcb45bc1 36 36 37 37 __exit() { 38 [ "$1" != "0" ] && echo "H_ERR=1" >> $ENVFILE38 [ x"$1" != x"0" ] && echo "RT_ERR=1" >> $ENVFILE 39 39 exit $1 40 40 } … … 61 61 62 62 main_env_update() { 63 local t_mdent lastmatch= ""63 local t_mdent lastmatch= 64 64 65 65 # get submode from calling hook script 66 SUBMODE=$( dirname $0|sed '{ s/\(.*\/\)*//; s/\.d$//}')66 SUBMODE=$(echo ${0%/*} |sed '{ s/\(.*\/\)*//; s/\.d$//}') 67 67 68 68 # create env file 69 69 if ! [ -f "$ENVFILE" ] 70 70 then 71 [ -d $ (dirname $ENVFILE) ] || mkdir -p $(dirname $ENVFILE)71 [ -d ${ENVFILE%/*} ] || mkdir -p ${ENVFILE%/*} 72 72 echo "MDENT=0" >> $ENVFILE 73 73 echo "LASTLOG=0" >> $ENVFILE 74 74 75 if is_up 76 then 77 IFACE_STATE="up" 78 else 79 IFACE_STATE="down" 80 fi 75 is_up && IFACE_STATE="up" || IFACE_STATE="down" 81 76 echo "IFACE_STATE=$IFACE_STATE" >> $ENVFILE 82 77 83 if [ "$IFACE" !="lo" ]78 if [ x"$IFACE" != x"lo" ] 84 79 then 85 80 # search for existing lib files end evaluate iface type by using the appropriate … … 87 82 for lib in ${LIBDIR}/iftypes/* 88 83 do 89 if [ -f $lib ] 84 [ -f $lib ] && (. $lib; iface_type 2>&-) || continue 85 if [ -n "$lastmatch" ] 90 86 then 91 if (. $lib; iface_type 2>&-)87 if [ ${lib##*/} = ${lastmatch##*/} ] 92 88 then 93 if [ "$lastmatch" != "" ] 94 then 95 if [ "$(basename $lib)" = "$(basename $lastmatch)" ] 96 then 97 mprint -s "Warning: $lib overlays $lastmatch" 98 else 99 mprint -s "Error: iface type $lib overlays $lastmatch" 100 fi 101 fi 102 lastmatch=$lib 89 mprint -s "Warning: $lib overlays $lastmatch" 90 else 91 mprint -s "Error: iface type $lib overlays $lastmatch" 103 92 fi 104 93 fi 94 lastmatch=$lib 105 95 done 106 96 fi 107 97 108 if [ "$lastmatch" != "" ] 109 then 110 IFACE_TYPE=$(basename $lastmatch) 111 else 112 # if iface type isn't evaluated type "iface" is default 113 IFACE_TYPE="iface" 114 fi 98 # if iface type isn't evaluated type "iface" is default 99 [ -n "$lastmatch" ] && IFACE_TYPE=${lastmatch##*/} || IFACE_TYPE="iface" 115 100 116 101 # update env … … 131 116 132 117 main_pos_update() { 133 if [ "${MDENT:-0}" = "0" ] 134 then 135 STARTCOL="" 136 else 137 STARTCOL="[$(expr ${MDENT:-0} \* ${TAB})C" 138 fi 118 [ x"$MDENT" = x"0" ] && STARTCOL= || STARTCOL="[$(expr ${MDENT:-0} \* ${TAB})C" 139 119 sed 's/MDENT=[0-9]*/'MDENT=$MDENT'/' -i $ENVFILE 140 120 } … … 157 137 retval=$? 158 138 159 if [ $retval != 0 ] 160 then 161 if [ $retval != 127 ] 162 then 163 fail_preup 2>&- || exit 1 164 fi 165 fi 139 [ x"$retval" != x"0" -a x"$retval" != x"127" ] && { 140 fail_preup 2>&- || exit 1 141 } 166 142 167 143 config $RT_PREUP_PRINTING_OFF || mup … … 174 150 retval=$? 175 151 176 if [ $retval != 0]152 if [ x"$retval" != x"0" ] 177 153 then 178 154 … … 191 167 retval=$? 192 168 193 if [ $retval != 0 ] 194 then 195 if [ $retval != 127 ] 196 then 197 fail_up 2>&- || exit 1 198 fi 199 fi 169 [ x"$retval" != x"0" -a x"$retval" != x"127" ] && { 170 fail_up 2>&- || exit 1 171 } 200 172 201 173 if [ -d /tmp/ifupdown/pcode/${IFACE} ] … … 203 175 for dir in /tmp/ifupdown/pcode/${IFACE}/* 204 176 do 205 if [ -f ${dir}/postup ] 206 then 207 . ${dir}/postup 208 fi 177 [ -f ${dir}/postup ] || continue 178 . ${dir}/postup 209 179 done 210 180 fi … … 218 188 for dir in /tmp/ifupdown/pcode/${IFACE}/* 219 189 do 220 if [ -f ${dir}/predown ] 221 then 222 . ${dir}/predown 223 fi 190 [ -f ${dir}/predown ] || continue 191 . ${dir}/predown 224 192 done 225 193 fi … … 228 196 retval=$? 229 197 230 if [ $retval != 0 ] 231 then 232 if [ $retval != 127 ] 233 then 234 fail_down 2>&- || exit 1 235 fi 236 fi 198 [ x"$retval" != x"0" -a x"$retval" != x"127" ] && { 199 fail_down 2>&- || exit 1 200 } 237 201 238 202 config $RT_DOWN_PRINTING_OFF || mdown … … 268 232 retval=$? 269 233 270 if [ $retval != 0 ] 271 then 272 if [ $retval != 127 ] 273 then 274 fail_postdown 2>&- || exit 1 275 fi 276 fi 234 [ x"$retval" != x"0" -a x"$retval" != x"127" ] && { 235 fail_postdown 2>&- || exit 1 236 } 277 237 278 238 # pcode cleanup … … 283 243 for hook in ${LIBDIR}/${1}/${2} 284 244 do 285 if [ -f $hook ] 286 then 287 . $hook 288 eval $3 2>&- 289 retval=$? 290 [ $retval != 0 -a $retval != 127 ] && exit 1 291 return 292 fi 245 [ -f $hook ] || continue 246 . $hook 247 eval $3 2>&- 248 retval=$? 249 [ x"$retval" != x"0" -a x"$retval" != x"127" ] && exit 1 250 return 293 251 done 294 252 } … … 300 258 eval "${plugin##*/}_${1}" 2>&- 301 259 retval=$? 302 [ $retval != 0 -a $retval != 127] && exit 1260 [ x"$retval" != x"0" -a x"$retval" != x"127" ] && exit 1 303 261 done 304 262 } … … 307 265 case $SUBMODE in 308 266 if-pre-up) 309 [ "${IF_PRE_UP:-""}" != "" ] && eval $IF_PRE_UP267 [ -n "$IF_PRE_UP" ] && eval $IF_PRE_UP 310 268 ;; 311 269 if-up) 312 [ "${IF_UP:-""}" != "" ] && eval $IF_UP270 [ -n "$IF_UP" ] && eval $IF_UP 313 271 ;; 314 272 if-down) 315 [ "${IF_DOWN:-""}" != "" ] && eval $IF_DOWN273 [ -n "$IF_DOWN" ] && eval $IF_DOWN 316 274 ;; 317 275 if-post-down) 318 [ "${IF_POST_DOWN:-""}" != "" ] && eval $IF_POST_DOWN276 [ -n "$IF_POST_DOWN" ] && eval $IF_POST_DOWN 319 277 ;; 320 278 esac … … 330 288 . /etc/rc.conf 331 289 332 config $ {FWIFUPDOWN_DEBUG:=""}&& set -x290 config $FWIFUPDOWN_DEBUG && set -x 333 291 334 292 RT_PREUP_PRINTING_OFF=0 … … 340 298 RT_POSTDOWN_IFDOWN_CHECK_OFF=0 341 299 RT_BB_NOEXEC=0 300 RT_ERR=0 342 301 readonly ENVFILE="/tmp/ifupdown/env" 343 readonly INSTALLDIR="/lib/network"344 302 readonly LIBDIR="/etc/network" 345 303 IFACE_TYPE="none" 346 H_ERR=0347 304 348 305 alias exit="__exit" 349 306 alias ifup="__ifupdown ifup" 350 307 alias ifdown="__ifupdown ifdown" 351 [ -z "$ {KSH_VERSION:-""}" ] || alias which='whence -p'308 [ -z "$KSH_VERSION" ] || alias which='whence -p' 352 309 353 310 if ! [ -f /etc/network/mfunctions.sh ] … … 360 317 main_env_update 361 318 362 config $ H_ERR && built_in exit 1363 364 if [ "$IFACE_TYPE" !="iface" ]319 config $RT_ERR && built_in exit 1 320 321 if [ x"$IFACE_TYPE" != x"iface" ] 365 322 then 366 323 if [ -f "${LIBDIR}/iftypes/${IFACE_TYPE}" ]
Note:
See TracChangeset
for help on using the changeset viewer.
