Added handling of option 224 to udhcp

This commit is contained in:
Vlatko Dimic 2016-02-29 15:37:20 +01:00 committed by Sukru Senli
parent 8143b29d38
commit d4d189bd1e
2 changed files with 78 additions and 3 deletions

View file

@ -36,12 +36,12 @@ init_iup() {
local baseopts= local baseopts=
local reqopts="$(uci -q get network.wan.reqopts)" local reqopts="$(uci -q get network.wan.reqopts)"
local proto="$(uci -q get network.wan.proto)" local proto="$(uci -q get network.wan.proto)"
local iupopts="66 67 128" local iupopts="66 67 128 224"
local ropt iopt local ropt iopt
config_get enabled iup enabled "off" config_get enabled iup enabled "off"
for ropt in $reqopts; do for ropt in $reqopts; do
case $ropt in case $ropt in
66|67|128) ;; 66|67|128|224) ;;
*) baseopts="$baseopts $ropt" ;; *) baseopts="$baseopts $ropt" ;;
esac esac
done done
@ -49,7 +49,7 @@ init_iup() {
reqopts="$baseopts $iupopts" reqopts="$baseopts $iupopts"
for ropt in $reqopts; do for ropt in $reqopts; do
case $ropt in case $ropt in
66|67|128) [ $enabled == "on" ] && newreqopts="$newreqopts $ropt" ;; 66|67|128|224) [ $enabled == "on" ] && newreqopts="$newreqopts $ropt" ;;
*) newreqopts="$newreqopts $ropt" ;; *) newreqopts="$newreqopts $ropt" ;;
esac esac
done done

75
iup/files/sbin/iup224 Normal file
View file

@ -0,0 +1,75 @@
#!/bin/sh
. /usr/share/libubox/jshn.sh
if [ -z $1 ] ; then
echo "No argument"
exit 1
fi
if [ $(echo $1|grep -o "," | wc -l) -eq 0 ] ; then
url=$1
else
url=$(echo $1|cut -d',' -f1)
a=$(echo $1|cut -d',' -f2)
b=$(echo $1|cut -d',' -f3)
c=$(echo $1|cut -d',' -f4)
fi
echo "url" $url
echo "a" $a
echo "b" $b
echo "c" $c
currdate=$(date +"%Y-%m-%d")
active=0
if [ -z $a ] ; then
active=1
elif [ $a ] && [ $b ] && [ $a -lt 25 ] ; then
#Time
begin=$(date +%s -d"$currdate $a")
now=$(date +%s)
end=$((begin+3600*$b))
if [ $now -gt $begin ] && [ $now -lt $end ] ; then
active=1
fi
elif [ $a ] && [ $b ] && [ $c ] && [ $a -gt 25 ] ; then
#Date
y=$(echo $a| cut -c1-4)
m=$(echo $a| cut -c5-6)
d=$(echo $a| cut -c7-8)
begin=$(date +%s -d"$y-$m-$d $b")
now=$(date +%s)
end=$((begin+3600*$c))
if [ $now -gt $begin ] && [ $now -lt $end ] ; then
active=1
fi
else
echo "Bad format"
exit 1
fi
sofwareminuspath=${url##*/}
if [ $url ] && [ $active -eq 1 ]; then
echo "Software version to download $sofwareminuspath"
local sysinfo=$(ubus call router quest "{ \"info\": \"system\" }")
json_load "$sysinfo"
json_get_var firmware firmware
json_get_var filesystem filesystem
if [ "$filesystem" == "JFFS2" ] ; then
firmware=$firmware.w
else
firmware=$firmware.y
fi
if [ "$sofwareminuspath" == "${sofwareminuspath/$firmware/}" ] ; then
echo "Image found $url will start flashing"
/sbin/sysupgrade -v $url
else
echo "Will not update software, already up to date"
fi
fi