diff --git a/iup/files/sbin/iup b/iup/files/sbin/iup index f080f168d..2761a7381 100755 --- a/iup/files/sbin/iup +++ b/iup/files/sbin/iup @@ -71,8 +71,7 @@ reload () local pack pack=$(get_packages $1) v "Calling ubus call uci commit for $pack" - for packname in $pack - do + for packname in $pack ; do ubus call uci commit '{"config":"'$packname'"}' sleep 1 done @@ -118,10 +117,12 @@ handle_provisioning() { mkdir $IUPTEMP fi touch $IUPCONFFILES + config_get_bool enabled "$config" enabled "$default" config_get_bool defaultreset "$config" defaultreset config_get deckey "$config" deckey - if [ "$enabled" -eq 1 ]; then + + if [ "$enabled" -eq 1 ]; then if [ "$config" == "iup" ]; then v "Using url received in dhcp options" config_get url "$config" urliup @@ -131,26 +132,25 @@ handle_provisioning() { url=${url//\$MAC/$MAC} v "Downloading from url \"$url\"" - while [ $retry -le $RETRYSTOP ] - do - if [ ${url%%:*} == "tftp" ]; then - tftpfile=${url#*\/\/} - host=${tftpfile%%\/*} - tftpfile=${tftpfile#*\/} + while [ $retry -le $RETRYSTOP ]; do + if [ ${url%%:*} == "tftp" ]; then + tftpfile=${url#*\/\/} + host=${tftpfile%%\/*} + tftpfile=${tftpfile#*\/} - /usr/bin/tftp -l $IUPCONFFILES -r "$tftpfile" -g "$host" - else - get_image "$url" "cat" > $IUPCONFFILES - fi - if [ -s $IUPCONFFILES ]; then - v "Download finished" - retry=$((RETRYSTOP + 1)) - else - v "Download failed, retrying in $incsleep seconds" - sleep $incsleep - incsleep=$((incsleep * retry + number)) - retry=$((retry+1)) - fi + /usr/bin/tftp -l $IUPCONFFILES -r "$tftpfile" -g "$host" + else + get_image "$url" "cat" > $IUPCONFFILES + fi + if [ -s $IUPCONFFILES ]; then + v "Download finished" + retry=$((RETRYSTOP + 1)) + else + v "Download failed, retrying in $incsleep seconds" + sleep $incsleep + incsleep=$((incsleep * retry + number)) + retry=$((retry+1)) + fi done fi if [ ! -s "$IUPCONFFILES" ] && [ "$enabled" -eq 1 ]; then @@ -170,11 +170,11 @@ handle_Downloaded_file() KEY=${DECKEY:-$DESKEY} local img_type case "$(get_image_type "$IUPCONFFILES")" in - "INTENO") img_type=2 ;; - "CFE+FS") img_type=1 ;; - "FS") img_type=0 ;; - *) img_type="UNKNOWN";; - esac + "INTENO") img_type=2 ;; + "CFE+FS") img_type=1 ;; + "FS") img_type=0 ;; + *) img_type="UNKNOWN";; + esac if [ "$img_type" == "UNKNOWN" ] ; then case "$(hexdump -v -n 2 -e '1/1 "%02x"' $IUPCONFFILES)" in @@ -192,15 +192,13 @@ handle_Downloaded_file() save_usercfg cd $IUPTEMP tar xvzf $IUPCONFFILES - for f in $CONFILESLURP - do + for f in $CONFILESLURP ; do v "File to be applied $f and config $(cat $f)" uci -f $f import done pack=$(get_packages $CONFILESLURP) v "Packages to be commited: $pack" - for packname in $pack - do + for packname in $pack ; do uci commit $packname done apply_usercfg @@ -239,7 +237,7 @@ handle_Downloaded_file() v "Downloaded file is a firmware, will start reflashing" if [ "$defaultreset" -eq 1 ]; then v "Not saving configuration over reflash" - /sbin/sysupgrade -v -n $IUPCONFFILES + /sbin/sysupgrade -v -n $IUPCONFFILES else v "Saving configuration over reflash" /sbin/sysupgrade -v $IUPCONFFILES @@ -290,14 +288,14 @@ change_to_vlan() { # loop through the string, remove any word close to "base_dev". for word in ${wan_if}; do - #echo $word - case $word in - ${base_dev}*) # don't add if. - ;; - *) new_wan_if=${word}' '${new_wan_if} # add if. - #new_wan_if+=" ${word}" # probably not working in ash. - ;; - esac + #echo $word + case $word in + ${base_dev}*) # don't add if. + ;; + *) new_wan_if=${word}' '${new_wan_if} # add if. + #new_wan_if+=" ${word}" # probably not working in ash. + ;; + esac done # append new interface. new_wan_if=${new_wan_if}${base_dev}.${1} @@ -532,7 +530,6 @@ main() touch $IUPMD5 fi - local iupurl local configurl local software