mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-24 19:14:05 +08:00
Compare commits
49 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2fc14ab7b6 | ||
|
|
8450eb0222 | ||
|
|
6da9baae20 | ||
|
|
24d3a8ff8f | ||
|
|
4510fab7b5 | ||
|
|
6693e8b044 | ||
|
|
a96536863c | ||
|
|
e7ccc17227 | ||
|
|
a866f53300 | ||
|
|
f2856573ba | ||
|
|
62ffc9d09f | ||
|
|
a62b4af959 | ||
|
|
b51bbf8a81 | ||
|
|
cae188c58f | ||
|
|
b378f9d282 | ||
|
|
8991729ba9 | ||
|
|
83f844710b | ||
|
|
a54afcfd71 | ||
|
|
b97967ccca | ||
|
|
c37874b635 | ||
|
|
40bdae09b0 | ||
|
|
40ae768fad | ||
|
|
c94d1cbb2e | ||
|
|
d518078c59 | ||
|
|
e2a4d61ec9 | ||
|
|
75dfbb9f0b | ||
|
|
d4ab4b545e | ||
|
|
9922c9cdf2 | ||
|
|
e7b63568cc | ||
|
|
173040e05a | ||
|
|
6c62ea0d11 | ||
|
|
8f32bea7e2 | ||
|
|
4827f77d53 | ||
|
|
a7831be487 | ||
|
|
b869f70925 | ||
|
|
988c64dab7 | ||
|
|
a79d4ad6f2 | ||
|
|
0281d75a7d | ||
|
|
7f257980a2 | ||
|
|
2bda0c8231 | ||
|
|
dd1feb9bd0 | ||
|
|
ed107abe0e | ||
|
|
7968558847 | ||
|
|
692fced9f9 | ||
|
|
7f467c553a | ||
|
|
c6383f1d0d | ||
|
|
db87f6c673 | ||
|
|
32a6438946 | ||
|
|
ebbe738a6b |
@@ -455,6 +455,8 @@ define Package/asterisk18-mod/install
|
||||
$(INSTALL_DATA) ./files/asterisk.default $(1)/etc/default/asterisk
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/asterisk.init $(1)/etc/init.d/asterisk
|
||||
$(INSTALL_DIR) $(1)/etc/hotplug.d/iface
|
||||
$(INSTALL_BIN) ./files/asterisk.hotplug $(1)/etc/hotplug.d/iface/80-asterisk
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-sounds/install
|
||||
|
||||
18
asterisk-1.8.x-mod/files/asterisk.hotplug
Normal file
18
asterisk-1.8.x-mod/files/asterisk.hotplug
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
[ "$ACTION" = ifup ] || exit 0
|
||||
|
||||
config_load voice_client
|
||||
config_get bindintf SIP bindintf
|
||||
|
||||
[ "$INTERFACE" == "$bindintf" ] || exit 0
|
||||
|
||||
. /lib/functions/network.sh
|
||||
|
||||
if [ -n "$bindintf" ]; then
|
||||
network_get_ipaddr bindaddr "$bindintf"
|
||||
bindaddr="${bindaddr:-0.0.0.0}"
|
||||
sed -i "s/bindaddr=.*/bindaddr=$bindaddr/g" /etc/asterisk/sip.conf
|
||||
[ -e /var/run/asterisk/asterisk.ctl ] && /etc/init.d/asterisk reload
|
||||
fi
|
||||
|
||||
@@ -9,26 +9,9 @@ USE_PROCD=1
|
||||
NAME=asterisk
|
||||
PROG=/usr/sbin/asterisk
|
||||
DEFAULT=/etc/default/asterisk
|
||||
CONFDIR=/etc/asterisk
|
||||
|
||||
init_asterisk() {
|
||||
# do not start asterisk until the
|
||||
# router receives a default route
|
||||
config_load voice_client
|
||||
local bindintf
|
||||
config_get bindintf SIP bindintf ""
|
||||
if [ "$bindintf" == "" ]; then
|
||||
while ! ip r | grep -q default; do
|
||||
sleep 1
|
||||
done
|
||||
else
|
||||
network_get_ipaddr ip "$bindintf"
|
||||
while [ "$ip" == "" ]; do
|
||||
sleep 1
|
||||
network_flush_cache
|
||||
network_get_ipaddr ip "$bindintf"
|
||||
done
|
||||
fi
|
||||
|
||||
[ -f $DEFAULT ] && . $DEFAULT
|
||||
[ -d /var/run/asterisk ] || mkdir -p /var/run/asterisk
|
||||
[ -d /var/log/asterisk ] || mkdir -p /var/log/asterisk
|
||||
@@ -56,6 +39,7 @@ start_service() {
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
asterisk -rx "config reload $CONFDIR/sip.conf"
|
||||
asterisk -rx "core reload"
|
||||
asterisk -rx "dialplan reload"
|
||||
asterisk -rx "brcm reload"
|
||||
|
||||
@@ -19,14 +19,14 @@ export PLATFORM_INCLUDE:=platforms/iopsys/build.mk
|
||||
|
||||
export DATE:=$(shell date +%Y-%m-%d-%H-%M-%S)
|
||||
export LOGIN:=$(shell whoami)
|
||||
BASE_PKG_VERSION:=4.1.0
|
||||
PKG_RELEASE:=RC8
|
||||
BASE_PKG_VERSION:=4.2.0
|
||||
PKG_RELEASE:=RC7
|
||||
PKG_VERSION:=$(BASE_PKG_VERSION)-$(PKG_RELEASE)_$(DATE)_$(LOGIN)
|
||||
export PKG_VERSION
|
||||
|
||||
###########################--RELEASE--################################
|
||||
|
||||
PKG_SOURCE_VERSION:=5d13d0034c0174cdb6d66f09a458851fe54d810e
|
||||
PKG_SOURCE_VERSION:=ee66d278b90b931013f2bc1c7a69f24ef5c742ea
|
||||
ifeq ($(CONFIG_ICE_OPEN),y)
|
||||
BRCM_KERNEL_PROFILE=$(shell echo $(CONFIG_BCM_KERNEL_PROFILE) | sed s/\"//g)
|
||||
PKG_SOURCE_URL:=http://iopsys.inteno.se/iopsys/consumer/
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=icwmp
|
||||
PKG_VERSION:=3.0-2017-01-17
|
||||
PKG_VERSION:=3.0-2017-01-20
|
||||
PKG_FIXUP:=autoreconf
|
||||
PKG_SOURCE_URL:=http://public.inteno.se:/icwmp.git
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=cfe4253f37e127c9ef405802beeec05d3507cc6a
|
||||
PKG_SOURCE_VERSION:=5c39d8d99127010c8d553495cd318ced80531a04
|
||||
PKG_RELEASE=$(PKG_SOURCE_VERSION)
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
@@ -31,19 +31,16 @@ management_interfaces() {
|
||||
}
|
||||
|
||||
init_iup() {
|
||||
local polling_enabled
|
||||
local interval
|
||||
local starttime
|
||||
local nummber
|
||||
number=$RANDOM
|
||||
|
||||
if [ -f $CRONPATH ]; then
|
||||
echo "File $CRONPATH exists"
|
||||
else
|
||||
echo "File $CRONPATH did not exists"
|
||||
touch $CRONPATH
|
||||
fi
|
||||
[ -f $CRONPATH ] || touch $CRONPATH
|
||||
|
||||
config_load provisioning
|
||||
config_get polling_enabled polling enabled on
|
||||
config_get interval polling interval
|
||||
config_get starttime polling starttime
|
||||
|
||||
@@ -54,12 +51,12 @@ init_iup() {
|
||||
local newreqopts=
|
||||
local baseopts=
|
||||
local reqopts="$(uci -q get network.$net.reqopts)"
|
||||
local iupopts="66 67 128 224"
|
||||
local iupopts="66 67 128 224 225 226"
|
||||
local ropt iopt
|
||||
config_get enabled iup enabled "on"
|
||||
for ropt in $reqopts; do
|
||||
case $ropt in
|
||||
66|67|128|224) ;;
|
||||
66|67|128|224|225|226) ;;
|
||||
*) baseopts="$baseopts $ropt" ;;
|
||||
esac
|
||||
done
|
||||
@@ -67,7 +64,7 @@ init_iup() {
|
||||
reqopts="$baseopts $iupopts"
|
||||
for ropt in $reqopts; do
|
||||
case $ropt in
|
||||
66|67|128|224) [ $enabled == "on" ] && newreqopts="$newreqopts $ropt" ;;
|
||||
66|67|128|224|225|226) [ $enabled == "on" ] && newreqopts="$newreqopts $ropt" ;;
|
||||
*) newreqopts="$newreqopts $ropt" ;;
|
||||
esac
|
||||
done
|
||||
@@ -82,8 +79,18 @@ init_iup() {
|
||||
ubus call network reload
|
||||
#################################################################
|
||||
|
||||
if [ $polling_enabled == "off" ]; then
|
||||
sed -i "/\/sbin\/iup/d" $CRONPATH
|
||||
logger -s -t /etc/init.d/iup[$$] "Provisioning polling unscheduled" 2>/dev/console
|
||||
return
|
||||
fi
|
||||
|
||||
local log_hour=$starttime
|
||||
local log_minute
|
||||
local log_interval=$interval
|
||||
if [ $interval == "weekly" ]; then
|
||||
interval="0"
|
||||
log_interval="$log_interval/sunday"
|
||||
elif [ $interval == "hourly" ]; then
|
||||
interval='*'
|
||||
starttime='*'
|
||||
@@ -91,9 +98,7 @@ init_iup() {
|
||||
interval='*'
|
||||
fi
|
||||
let "number %= $RANGE"
|
||||
if grep -q "$starttime \* \* \\$interval /sbin/iup" "$CRONPATH" ; then
|
||||
echo "IUP is scheduled $starttime \* \* \\$interval "
|
||||
else
|
||||
if ! grep -q "$starttime \* \* \\$interval /sbin/iup" "$CRONPATH" ; then
|
||||
if grep -q "iup" "$CRONPATH" ; then
|
||||
sed -i "/iup/d" $CRONPATH
|
||||
fi
|
||||
@@ -101,15 +106,14 @@ init_iup() {
|
||||
fsync $CRONPATH
|
||||
/etc/init.d/cron restart
|
||||
fi
|
||||
log_minute=$(awk '/\/sbin\/iup/ {print $1}' /etc/crontabs/root)
|
||||
logger -s -t /etc/init.d/iup[$$] "Provisioning is scheduled at $log_hour:$log_minute $log_interval" 2>/dev/console
|
||||
}
|
||||
|
||||
start_service() {
|
||||
init_iup
|
||||
|
||||
test_default_route
|
||||
if [ "$?" -eq 0 ]; then
|
||||
/sbin/iup -v &
|
||||
fi
|
||||
/sbin/iup -v &
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
|
||||
@@ -26,28 +26,15 @@ MAC=${MAC// /}
|
||||
#lower to upper Conversion
|
||||
MAC=$(echo $MAC | tr '[a-z]' '[A-Z]')
|
||||
|
||||
# no verbose: no output
|
||||
# -v log to system log
|
||||
# -v -v log to system log and console
|
||||
# -v -v -v log to system log, console and stderr
|
||||
v() {
|
||||
[ "$VERBOSE" -ge 1 ] && logger -t iup "$@"
|
||||
}
|
||||
|
||||
if [ -f $IUPMD5 ]; then
|
||||
v "File $IUPMD5 exists"
|
||||
else
|
||||
v "File $IUPMD5 did not exists"
|
||||
touch $IUPMD5
|
||||
fi
|
||||
|
||||
handle_ucitrack()
|
||||
{
|
||||
local config="$1"
|
||||
config_get init "$config" init
|
||||
echo $init
|
||||
config_get affects "$config" affects
|
||||
|
||||
for aff in $affects
|
||||
do
|
||||
config_foreach handle_ucitrack $aff
|
||||
done
|
||||
[ "$VERBOSE" -eq 0 ] && return
|
||||
[ "$VERBOSE" -eq 1 ] && logger -t $0[$$] "$@" && return
|
||||
[ "$VERBOSE" -eq 2 ] && logger -s -t $0[$$] "$@" >/dev/console 2>&1 && return
|
||||
[ "$VERBOSE" -eq 3 ] && logger -s -t $0[$$] "$@" 2>&1 | tee /dev/console && return
|
||||
}
|
||||
|
||||
get_packages()
|
||||
@@ -61,35 +48,13 @@ get_packages()
|
||||
|
||||
reload ()
|
||||
{
|
||||
local reload
|
||||
local initlist
|
||||
local reload
|
||||
local pack
|
||||
pack=$(get_packages $1)
|
||||
config_load ucitrack
|
||||
v "Calling ubus call uci commit for $pack"
|
||||
for packname in $pack
|
||||
do
|
||||
initlist=$(config_foreach handle_ucitrack $packname)
|
||||
for reltest in $initlist
|
||||
do
|
||||
case $reload in
|
||||
*" $reltest "*) v "already added to reload $reltest" ;;
|
||||
*) reload="$reload"" ""$reltest" ;;
|
||||
esac
|
||||
done
|
||||
ubus call uci commit '{"config":"'$packname'"}'
|
||||
done
|
||||
v "Init scripts to be run $reload"
|
||||
for inittoreload in $reload
|
||||
do
|
||||
if [ "$inittoreload" != "iup" ]; then
|
||||
/etc/init.d/$inittoreload restart
|
||||
fi
|
||||
done
|
||||
#Ugly hack need to figure out something here
|
||||
test_default_route
|
||||
if [ "$?" -eq 1 ]; then
|
||||
sleep 5
|
||||
fi
|
||||
}
|
||||
|
||||
handle_provisioning() {
|
||||
@@ -117,15 +82,15 @@ handle_provisioning() {
|
||||
config_get deckey "$config" deckey
|
||||
if [ "$enabled" -eq 1 ]; then
|
||||
if [ "$config" == "iup" ]; then
|
||||
v "using url from dhcp options"
|
||||
v "Using url received in dhcp options"
|
||||
config_get url "$config" urliup
|
||||
else
|
||||
else
|
||||
config_get url "$config" url
|
||||
fi
|
||||
url=${url//\$MAC/$MAC}
|
||||
v "Download from $url"
|
||||
|
||||
while [ $retry -le $RETRYSTOP ]
|
||||
v "Downloading from url \"$url\""
|
||||
|
||||
while [ $retry -le $RETRYSTOP ]
|
||||
do
|
||||
if [ ${url%%:*} == "tftp" ]; then
|
||||
tftpfile=${url#*\/\/}
|
||||
@@ -137,10 +102,10 @@ handle_provisioning() {
|
||||
get_image "$url" "cat" > $IUPCONFFILES
|
||||
fi
|
||||
if [ -s $IUPCONFFILES ]; then
|
||||
v "File Downloaded"
|
||||
v "Download finished"
|
||||
retry=$((RETRYSTOP + 1))
|
||||
else
|
||||
v "Download failed will try again in $incsleep sec"
|
||||
else
|
||||
v "Download failed, retrying in $incsleep seconds"
|
||||
sleep $incsleep
|
||||
incsleep=$((incsleep * retry + number))
|
||||
retry=$((retry+1))
|
||||
@@ -163,35 +128,35 @@ handle_Downloaded_file()
|
||||
[ -n "$1" ] && DECKEY=$(echo $1 | tr -d '\n' | hexdump -e '16/1 "%02x"')
|
||||
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
|
||||
|
||||
case "$(get_image_type "$IUPCONFFILES")" in
|
||||
"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
|
||||
1f8b)
|
||||
v "Found Config"
|
||||
v "Downloaded file is an unencrypted config"
|
||||
md5=$(md5sum $IUPCONFFILES)
|
||||
md5="${md5%% *}" # remove the first space and everything after it
|
||||
md5sum "$IUPCONFFILES" >> "$IUPMD5.temp"
|
||||
if grep -q "$md5" "$IUPMD5"; then
|
||||
v "Config Already Up to Date"
|
||||
#becuse config is up to date we need to disable last step reboot if set
|
||||
v "Config is already up to date, nothing to do"
|
||||
#because config is up to date we need to disable last step reboot if set
|
||||
reboot="off"
|
||||
rm -rf $IUPTEMP
|
||||
else
|
||||
cd /tmp/iup/
|
||||
cd $IUPTEMP
|
||||
tar xvzf $IUPCONFFILES
|
||||
for f in $CONFILESLURP
|
||||
do
|
||||
v "file to be applied $f and config $(cat $f)"
|
||||
v "File to be applied $f and config $(cat $f)"
|
||||
uci import -f $f
|
||||
done
|
||||
pack=$(get_packages $CONFILESLURP)
|
||||
v "$pack packages to be commited"
|
||||
v "Packages to be commited: $pack"
|
||||
for packname in $pack
|
||||
do
|
||||
uci commit $packname
|
||||
@@ -207,11 +172,11 @@ handle_Downloaded_file()
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
v "encrypted"
|
||||
v "Downloaded file is an encrypted config"
|
||||
if [ $KEY ]; then
|
||||
openssl enc -d -des-ede -nosalt -K $KEY -iv "0000000000000000" -in $IUPCONFFILES -out $IUPCONFFILES.tmp
|
||||
if [ $? -eq 0 ]; then
|
||||
v "Decrypted Content"
|
||||
v "Decryption successful"
|
||||
mv $IUPCONFFILES.tmp $IUPCONFFILES
|
||||
handle_Downloaded_file
|
||||
else
|
||||
@@ -227,11 +192,12 @@ handle_Downloaded_file()
|
||||
;;
|
||||
esac
|
||||
else
|
||||
v "Image found will start flashing"
|
||||
v "Downloaded file is a firmware, will start reflashing"
|
||||
if [ "$defaultreset" -eq 1 ]; then
|
||||
v "nuke config"
|
||||
v "Not saving configuration over reflash"
|
||||
/sbin/sysupgrade -v -n $IUPCONFFILES
|
||||
else
|
||||
v "Saving configuration over reflash"
|
||||
/sbin/sysupgrade -v $IUPCONFFILES
|
||||
fi
|
||||
fi
|
||||
@@ -253,7 +219,7 @@ change_to_vlan() {
|
||||
|
||||
# bring down old interface/device.
|
||||
ifdown "${base_dev}"
|
||||
logger -t dhcp_opt132 "bringing down old if: ${base_dev}"
|
||||
v "option 132: bringing down old if: ${base_dev}"
|
||||
|
||||
# extract base name of device.
|
||||
base_dev=$(echo ${base_dev} | cut -d. -f1)
|
||||
@@ -267,15 +233,15 @@ change_to_vlan() {
|
||||
uci set layer2_interface_vlan.@vlan_interface[-1].baseifname=${base_dev}
|
||||
# and commit the change.
|
||||
uci commit layer2_interface_vlan
|
||||
logger -t dhcp_opt132 "committed update to file layer2_interface_vlan"
|
||||
v "option 132: committed update to file layer2_interface_vlan"
|
||||
|
||||
# reload configuration files.
|
||||
/etc/init.d/layer2_interface_vlan reload
|
||||
logger -t dhcp_opt132 "reload layer2_interface_vlan config"
|
||||
v "option 132: reload layer2_interface_vlan config"
|
||||
|
||||
# replace old interface (like eth0.1 with new eth0.101).
|
||||
wan_if=$(uci get network.$3.ifname)
|
||||
logger -t dhcp_opt132 "old network.${3}.ifname: $wan_if"
|
||||
v "option 132: old network.${3}.ifname: $wan_if"
|
||||
|
||||
# loop through the string, remove any word close to "base_dev".
|
||||
for word in ${wan_if}; do
|
||||
@@ -293,10 +259,12 @@ change_to_vlan() {
|
||||
uci set network.wan.ifname="${new_wan_if}"
|
||||
# and commit the change.
|
||||
uci commit network
|
||||
logger -t dhcp_opt132 "committed update to file network: ifname=${new_wan_if}"
|
||||
v "option 132: committed update to file network: ifname=${new_wan_if}"
|
||||
|
||||
# reboot into new if configuration.
|
||||
reboot
|
||||
v "Rebooting"
|
||||
export REBOOT_REASON=iup
|
||||
/sbin/reboot
|
||||
}
|
||||
|
||||
handle_option224()
|
||||
@@ -347,69 +315,67 @@ handle_option224()
|
||||
softwareminuspath=${url##*/}
|
||||
|
||||
if [ $url ] && [ $active -eq 1 ]; then
|
||||
echo "Software version to download $softwareminuspath"
|
||||
v "Software version to download \"$softwareminuspath\""
|
||||
local sysinfo=$(ubus call router.system info)
|
||||
json_load "$sysinfo"
|
||||
json_select system
|
||||
json_get_var firmware firmware
|
||||
local firmware_new=${softwareminuspath%.*} # remove extension (.w, .y or .y2) from filename
|
||||
if [ "$firmware_new" != "$firmware" ] ; then
|
||||
echo "Image found $url will start flashing"
|
||||
v "Firmware found $url will start flashing"
|
||||
v "Currently running firmware: \"$firmware\""
|
||||
v "Newly received firmware: \"$firmware_new\""
|
||||
wait_for_dns $url
|
||||
v "Start flashing"
|
||||
/sbin/sysupgrade -v $url &
|
||||
return 1
|
||||
else
|
||||
echo "Will not update software, already up to date"
|
||||
v "Firmware is up to date, nothing to do"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
### MAIN ###
|
||||
while [ -n "$1" ]; do
|
||||
case "$1" in
|
||||
-v) export VERBOSE="$(($VERBOSE + 1))";;
|
||||
-q) export VERBOSE="$(($VERBOSE - 1))";;
|
||||
-*)
|
||||
echo "Invalid option: $1"
|
||||
exit 1
|
||||
;;
|
||||
*) break;;
|
||||
esac
|
||||
shift;
|
||||
done
|
||||
|
||||
# Process IUP related DHCP options #
|
||||
if [ -n "$1" ]; then
|
||||
parse_dhcp_options()
|
||||
{
|
||||
local the_json="$@"
|
||||
# Process IUP related DHCP options #
|
||||
local privopt224 privopt225 privopt226 vendorspecinf httpurl128
|
||||
local tftp bootfile vlanid vlanpriority interface
|
||||
|
||||
json_load "$1"
|
||||
json_load "$the_json"
|
||||
json_get_var interface interface
|
||||
json_get_var privopt224 privopt224
|
||||
json_get_var privopt225 privopt225
|
||||
json_get_var privopt226 privopt226
|
||||
json_get_var vendorspecinf vendorspecinf
|
||||
json_get_var vendorspecinf vendorspecinf # option 43
|
||||
json_get_var httpurl128 httpurl128
|
||||
json_get_var tftp tftp
|
||||
json_get_var bootfile bootfile
|
||||
json_get_var vlanid vlanid
|
||||
json_get_var vlanpriority vlanpriority
|
||||
json_get_var tftp tftp # option 66
|
||||
json_get_var bootfile bootfile #option 67
|
||||
json_get_var vlanid vlanid # option 132
|
||||
json_get_var vlanpriority vlanpriority # option 133
|
||||
|
||||
v "Processing dhcp options"
|
||||
|
||||
if [ $privopt224 ]; then
|
||||
echo "Option224 recived " $privopt224 > /dev/console
|
||||
v "dhcp option 224 firmware url $privopt224"
|
||||
handle_option224 $privopt224
|
||||
[ $? -eq 1 ] && exit
|
||||
fi
|
||||
|
||||
if [ $vendorspecinf ]; then
|
||||
v "dhcp option 43 tr69 url $vendorspecinf"
|
||||
url=${vendorspecinf%%,*}; rest=${vendorspecinf#*,}
|
||||
provisioningcode=${rest%%,*};
|
||||
uci_set_state provisioning iup urlcwmp "$url"
|
||||
uci_set_state provisioning iup url "$url"
|
||||
uci_set_state provisioning iup provisioningcode "$provisioningcode"
|
||||
elif [ $httpurl128 ]; then
|
||||
v "dhcp option 128 http config url $httpurl128"
|
||||
uci_set_state provisioning iup urliup "$httpurl128"
|
||||
elif [ $tftp ]; then
|
||||
v "dhcp option 66 tftp config url $tftp"
|
||||
if [ ${bootfile:0:1} == '/' ]; then
|
||||
uci_set_state provisioning iup urliup "tftp://$tftp$bootfile"
|
||||
else
|
||||
@@ -417,17 +383,17 @@ if [ -n "$1" ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# if we get vlanid and maybe vlanpriority, configure for that.
|
||||
# vlanid (and vlanpriority)
|
||||
if [ -n "$vlanid" -a -n "$vlanpriority" ]; then
|
||||
logger -t dhcp_opt132 "vlanid: ${vlanid}, vlanpriority: ${vlanpriority}"
|
||||
v "dhcp option 132 vlanid: ${vlanid} vlanpriority: ${vlanpriority}"
|
||||
change_to_vlan ${vlanid} ${vlanpriority} ${interface}
|
||||
elif [ -n "$vlanid" ]; then
|
||||
logger -t dhcp_opt132 "vlanid: ${vlanid}"
|
||||
v "dhcp option 132 vlanid: ${vlanid}"
|
||||
change_to_vlan ${vlanid} 0 ${interface}
|
||||
elif [ -n "$privopt225" ] || [ -n "$privopt226" ]; then
|
||||
# opt225 and opt226 can be used together or separatly
|
||||
if [ -n "$privopt225" ]; then
|
||||
echo "dhcp option 225: $privopt225" >/dev/console
|
||||
v "dhcp option 225: $privopt225"
|
||||
# option225 is allowd to change only once per CPE
|
||||
if [ "$(uci get -q ice.cloud.frozen)" != "1" ] ; then
|
||||
uci set ice.cloud.frozen="1"
|
||||
@@ -436,69 +402,137 @@ if [ -n "$1" ]; then
|
||||
fi
|
||||
fi
|
||||
if [ -n "$privopt226" ]; then
|
||||
echo "dhcp option 226: $privopt226" >/dev/console
|
||||
v "dhcp option 226: $privopt226"
|
||||
[ -z "$(uci get -q ice.dhcp)" ] && uci set ice.dhcp="dhcp"
|
||||
uci set ice.dhcp.opt226connectionid="$privopt226"
|
||||
ubus send dhcp.opt226connectionid '{"opt226connectionid":"","value":"'$privopt226'"}'
|
||||
fi
|
||||
uci commit
|
||||
fi
|
||||
}
|
||||
|
||||
exit 0
|
||||
fi
|
||||
# wait_for_default_gateway to become reachable
|
||||
# return 0 if the default gateway is reachable
|
||||
# return 1 if the default gateway is not reachable after $wait_time
|
||||
wait_for_default_gateway()
|
||||
{
|
||||
local gateway
|
||||
local device
|
||||
local wait_time=120
|
||||
local wait_interval=10
|
||||
|
||||
local iupurl
|
||||
local configurl
|
||||
local software
|
||||
local sofwareminuspath
|
||||
while [ true ] ; do
|
||||
|
||||
config_load provisioning
|
||||
#check if iup should be used or if its overridden by /etc/config
|
||||
config_get configurl configserver url
|
||||
config_get reboot configserver reboot
|
||||
config_get iupurl iup urliup
|
||||
gateway=""
|
||||
device=""
|
||||
network_flush_cache
|
||||
network_get_gateway gateway wan #true
|
||||
network_get_device device wan
|
||||
device="${device:+-I }$device"
|
||||
if ping -q -w 1 -c 1 $device $gateway >/dev/null 2>&1 ; then
|
||||
[ "$wait_time" -lt "60" ] && v "Default gateway $gateway is reachable"
|
||||
sleep $wait_interval
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ $configurl ]; then
|
||||
handle_provisioning configserver "0"
|
||||
elif [ $iupurl ]; then
|
||||
handle_provisioning iup "1"
|
||||
else
|
||||
v "No Provisioning Server Found"
|
||||
exit
|
||||
fi
|
||||
v "Waiting for default gateway. Countdown $wait_time seconds"
|
||||
sleep $wait_interval
|
||||
wait_time=$((wait_time - wait_interval))
|
||||
[ "$wait_time" -le "0" ] && break # timer expired
|
||||
done
|
||||
|
||||
config_load provisioning
|
||||
config_foreach handle_provisioning subconfig "0"
|
||||
config_get software uppgradeserver url
|
||||
sofwareminuspath=${software##*/}
|
||||
v "Software version to download $sofwareminuspath"
|
||||
return 1 # default gateway not reachable
|
||||
}
|
||||
|
||||
if [ $software ]; then
|
||||
local sysinfo=$(ubus call router.system info)
|
||||
json_load "$sysinfo"
|
||||
json_select system
|
||||
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 $software
|
||||
handle_provisioning uppgradeserver "0"
|
||||
else
|
||||
v "Will not update software, already up to date"
|
||||
|
||||
main()
|
||||
{
|
||||
|
||||
while [ -n "$1" ]; do
|
||||
case "$1" in
|
||||
-v) export VERBOSE="$(($VERBOSE + 1))";;
|
||||
-q) export VERBOSE="$(($VERBOSE - 1))";;
|
||||
--dhcp-options)
|
||||
shift
|
||||
parse_dhcp_options "$@"
|
||||
exit 0
|
||||
;;
|
||||
-*)
|
||||
echo "Invalid option: $1"
|
||||
exit 1
|
||||
;;
|
||||
*) break;;
|
||||
esac
|
||||
shift;
|
||||
done
|
||||
|
||||
if ! wait_for_default_gateway ; then
|
||||
v "Default gateway is not reachable. Aborting iup."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $CONF -eq 1 ]; then
|
||||
mv "$IUPMD5.temp" $IUPMD5
|
||||
fi
|
||||
if [ ! -f $IUPMD5 ]; then
|
||||
v "Creating file $IUPMD5"
|
||||
touch $IUPMD5
|
||||
fi
|
||||
|
||||
if [ "$reboot" == "on" ]; then
|
||||
v "Reboot Signaled"
|
||||
/sbin/reboot
|
||||
fi
|
||||
|
||||
rm -rf /var/run/iup.pid
|
||||
local iupurl
|
||||
local configurl
|
||||
local software
|
||||
local sofwareminuspath
|
||||
|
||||
config_load provisioning
|
||||
#check if iup should be used or if its overridden by /etc/config
|
||||
config_get configurl configserver url
|
||||
config_get reboot configserver reboot
|
||||
config_get iupurl iup urliup
|
||||
|
||||
if [ $configurl ]; then
|
||||
handle_provisioning configserver "0"
|
||||
elif [ $iupurl ]; then
|
||||
handle_provisioning iup "1"
|
||||
else
|
||||
v "No provisioning server configured"
|
||||
exit
|
||||
fi
|
||||
|
||||
config_load provisioning
|
||||
config_foreach handle_provisioning subconfig "0"
|
||||
config_get software uppgradeserver url
|
||||
sofwareminuspath=${software##*/}
|
||||
|
||||
if [ $software ]; then
|
||||
v "Software version to download \"$sofwareminuspath\""
|
||||
local sysinfo=$(ubus call router.system info)
|
||||
json_load "$sysinfo"
|
||||
json_select system
|
||||
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
|
||||
v "Software \"$software\""
|
||||
handle_provisioning uppgradeserver "0"
|
||||
else
|
||||
v "Will not update software, already up to date"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $CONF -eq 1 ]; then
|
||||
mv "$IUPMD5.temp" $IUPMD5
|
||||
fi
|
||||
|
||||
if [ "$reboot" == "on" ]; then
|
||||
v "Rebooting"
|
||||
export REBOOT_REASON=iup
|
||||
/sbin/reboot
|
||||
fi
|
||||
|
||||
rm -rf /var/run/iup.pid
|
||||
}
|
||||
|
||||
main $@
|
||||
|
||||
@@ -156,11 +156,22 @@ wlmngr_startServices() {
|
||||
|
||||
enableBSD() {
|
||||
local wdev wdev_to_steer
|
||||
local enabled policy
|
||||
local rssi_threshold bw_util
|
||||
|
||||
nvram set bsd_role=0
|
||||
nvram unset bsd_ifnames
|
||||
|
||||
[ "$(uci -q get wireless.status.bandsteering)" == "1" ] || return 1
|
||||
enabled="$(uci -q get wireless.bandsteering.enabled)"
|
||||
|
||||
[ "$enabled" == "1" ] || return 1
|
||||
|
||||
policy="$(uci -q get wireless.bandsteering.policy)"
|
||||
policy=${policy:-0}
|
||||
rssi_threshold="$(uci -q get wireless.bandsteering.rssi_threshold)"
|
||||
rssi_threshold=${rssi_threshold:--75}
|
||||
bw_util="$(uci -q get wireless.bandsteering.bw_util)"
|
||||
bw_util=${bw_util:--60}
|
||||
|
||||
nvram set bsd_role=3
|
||||
nvram set bsd_pport=9878
|
||||
@@ -179,20 +190,40 @@ enableBSD() {
|
||||
nvram set bsd_ifnames="$(nvram get bsd_ifnames) $wdev"
|
||||
[ "$wdev" == "wl0" ] && wdev_to_steer="wl1" || wdev_to_steer="wl0"
|
||||
|
||||
if [ "$(nvram get ${wdev}_nband)" == "2" ]; then
|
||||
# 2.4G
|
||||
nvram set ${wdev}_bsd_if_quality_policy="0 0x0 -100"
|
||||
nvram set ${wdev}_bsd_if_select_policy=$wdev_to_steer
|
||||
nvram set ${wdev}_bsd_sta_select_policy="10 0 0 0 1 1 0 0 0 0x400"
|
||||
nvram set ${wdev}_bsd_steer_prefix=$wdev
|
||||
nvram set ${wdev}_bsd_steering_policy="0 5 3 0 0 0x1"
|
||||
if [ "$policy" == "0" ]; then
|
||||
# RSSI Threshold based policy #
|
||||
if [ "$(nvram get ${wdev}_nband)" == "2" ]; then
|
||||
# 2.4G
|
||||
nvram set ${wdev}_bsd_if_quality_policy="0 0x0 -100"
|
||||
nvram set ${wdev}_bsd_if_select_policy=$wdev_to_steer
|
||||
nvram set ${wdev}_bsd_sta_select_policy="0 0 0 0 0 1 0 0 0 0x600"
|
||||
nvram set ${wdev}_bsd_steer_prefix=$wdev
|
||||
nvram set ${wdev}_bsd_steering_policy="0 5 3 0 0 0x10"
|
||||
else
|
||||
# 5G
|
||||
nvram set ${wdev}_bsd_if_quality_policy="40 0x0 $rssi_threshold"
|
||||
nvram set ${wdev}_bsd_if_select_policy=$wdev_to_steer
|
||||
nvram set ${wdev}_bsd_sta_select_policy="0 0 0 0 0 1 0 0 0 0x240"
|
||||
nvram set ${wdev}_bsd_steer_prefix=$wdev
|
||||
nvram set ${wdev}_bsd_steering_policy="80 5 3 $rssi_threshold 0 0x40"
|
||||
fi
|
||||
else
|
||||
# 5G
|
||||
nvram set ${wdev}_bsd_if_quality_policy="20 0x0 -75"
|
||||
nvram set ${wdev}_bsd_if_select_policy=$wdev_to_steer
|
||||
nvram set ${wdev}_bsd_sta_select_policy="100 0 0 0 0 1 0 0 0 0x40"
|
||||
nvram set ${wdev}_bsd_steer_prefix=$wdev
|
||||
nvram set ${wdev}_bsd_steering_policy="80 5 3 -75 0 0x40"
|
||||
# Bandwidth Usage based policy #
|
||||
if [ "$(nvram get ${wdev}_nband)" == "2" ]; then
|
||||
# 2.4G
|
||||
nvram set ${wdev}_bsd_if_quality_policy="0 0x0 -75"
|
||||
nvram set ${wdev}_bsd_if_select_policy=$wdev_to_steer
|
||||
nvram set ${wdev}_bsd_sta_select_policy="0 0 0 0 0 1 0 0 0 0x600"
|
||||
nvram set ${wdev}_bsd_steer_prefix=$wdev
|
||||
nvram set ${wdev}_bsd_steering_policy="0 5 3 0 0 0x10"
|
||||
else
|
||||
# 5G
|
||||
nvram set ${wdev}_bsd_if_quality_policy="40 0x0 -75"
|
||||
nvram set ${wdev}_bsd_if_select_policy=$wdev_to_steer
|
||||
nvram set ${wdev}_bsd_sta_select_policy="0 0 0 0 0 1 0 0 0 0x240"
|
||||
nvram set ${wdev}_bsd_steer_prefix=$wdev
|
||||
nvram set ${wdev}_bsd_steering_policy="$bw_util 5 3 0 0 0x40"
|
||||
fi
|
||||
fi
|
||||
#fi
|
||||
done
|
||||
|
||||
@@ -58,6 +58,19 @@ ifbaseexists()
|
||||
return 0
|
||||
}
|
||||
|
||||
check_mac_address()
|
||||
{
|
||||
local baseifname="$1"
|
||||
local vlan="$2"
|
||||
local basemac
|
||||
local mac=$(ifconfig -a | grep "^${baseifname}.${vlan} " | awk '{print $NF}')
|
||||
local mac_in_use=$(ifconfig -a | grep "$mac" | grep -v "^${baseifname}.${vlan}[ ]")
|
||||
if [ "$mac_in_use" ]; then
|
||||
basemac=$(ifconfig -a | grep "^$baseifname " | awk '{print $NF}')
|
||||
ifconfig ${baseifname}.${vlan} hw ether $basemac
|
||||
fi
|
||||
}
|
||||
|
||||
addbrcmvlan()
|
||||
{
|
||||
local baseifname=$1
|
||||
@@ -102,9 +115,11 @@ addbrcmvlan()
|
||||
vlanctl --if-create $baseifname $vlan8021q
|
||||
else
|
||||
vlanctl --dhcp-bridged --if-create $baseifname $vlan8021q
|
||||
check_mac_address $baseifname $vlan8021q
|
||||
fi
|
||||
else
|
||||
vlanctl --routed --if-create $baseifname $vlan8021q
|
||||
check_mac_address $baseifname $vlan8021q
|
||||
fi
|
||||
|
||||
if [ "$bridge" -eq 1 ]; then
|
||||
|
||||
@@ -12,7 +12,7 @@ PKG_NAME:=peripheral_manager
|
||||
PKG_VERSION:=1.0.0
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_VERSION:=db710fed768e20fba40212e11fa4191593e168fc
|
||||
PKG_SOURCE_VERSION:=abe58070db6a616eb4f24304f0613c9d67a77775
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=http://public.inteno.se/peripheral_manager
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ include $(INCLUDE_DIR)/kernel.mk
|
||||
PKG_NAME:=questd
|
||||
PKG_VERSION:=3.1.28
|
||||
|
||||
PKG_SOURCE_VERSION:=44105d2003ad530b8ba4e85fd6ac06850aec1f4c
|
||||
PKG_SOURCE_VERSION:=29091b62f1adc61a6e09e442dc3a4c492b55fd7a
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=http://public.inteno.se:/questd
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@ start_service() {
|
||||
procd_set_param command "/sbin/questd"
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
|
||||
pidof questd-monitor > /dev/null 2>&1 || /sbin/questd-monitor &
|
||||
}
|
||||
|
||||
stop() {
|
||||
|
||||
160
questd/files/sbin/questd-monitor
Executable file
160
questd/files/sbin/questd-monitor
Executable file
@@ -0,0 +1,160 @@
|
||||
#!/bin/sh
|
||||
|
||||
# 1. sleep for $SLEEP_LONG seconds
|
||||
# 2. run the check_* functions
|
||||
# 3. sleep for $SLEEP_SHORT seconds
|
||||
# 4. go to step 2. $SAMPLES-1 times (step 2. will run $SAMPLES times)
|
||||
# 5. go to step 1.
|
||||
SAMPLES=4
|
||||
SLEEP_SHORT=2
|
||||
SLEEP_LONG=10
|
||||
|
||||
# worst-case scenario:
|
||||
# quest will be restarted in:
|
||||
# SLEEP_LONG + (SAMPLES-1)*SLEEP_SHORT + UBUS_TIMEOUT + epsilon =
|
||||
# = 21 seconds
|
||||
|
||||
# number of process
|
||||
NPROC_LIMIT=2 # the value that is considered to be wrong (and above)
|
||||
NPROC_COUNT=4 # number of time that the NPROC_LIMIT has to be hit to trigger a process restart
|
||||
NPROC_NFAIL=0 # current consecutive Number of FAILures. process restarts when NPROC_NFAIL == NPROC_COUNT
|
||||
|
||||
# memmory limit
|
||||
MEM_LIMIT=50000
|
||||
MEM_COUNT=4
|
||||
MEM_NFAIL=0
|
||||
|
||||
# procentage of CPU usage
|
||||
PCPU_LIMIT=38
|
||||
PCPU_COUNT=4
|
||||
PCPU_NFAIL=0
|
||||
|
||||
UBUS_TIMEOUT=5
|
||||
|
||||
|
||||
restart_questd()
|
||||
{
|
||||
logger -s -t $0[$$] "Restarting questd. $NPROC_NFAIL $MEM_NFAIL $PCPU_NFAIL"
|
||||
|
||||
killall -q -KILL questd
|
||||
/etc/init.d/quest stop
|
||||
killall -q -KILL questd
|
||||
/etc/init.d/quest start
|
||||
|
||||
NPROC_NFAIL=0
|
||||
MEM_NFAIL=0
|
||||
PCPU_NFAIL=0
|
||||
}
|
||||
|
||||
|
||||
check_nproc()
|
||||
{
|
||||
local nproc="$@"
|
||||
|
||||
if [ "$nproc" -ge "$NPROC_LIMIT" -o "$nproc" -eq "0" ]; then
|
||||
NPROC_NFAIL=$((NPROC_NFAIL + 1))
|
||||
else
|
||||
NPROC_NFAIL=0
|
||||
fi
|
||||
|
||||
[ "$NPROC_NFAIL" -ge "$NPROC_COUNT" ] && return 1
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
check_mem()
|
||||
{
|
||||
local mem="$@"
|
||||
local ok=true
|
||||
|
||||
for m in $mem; do
|
||||
if [ "$m" -ge "$MEM_LIMIT" ]; then
|
||||
ok=false
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
[ "$ok" = "true" ] && MEM_NFAIL=0
|
||||
[ "$ok" = "false" ] && MEM_NFAIL=$((MEM_NFAIL + 1))
|
||||
|
||||
[ "$MEM_NFAIL" -ge "$MEM_COUNT" ] && return 1
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
check_pcpu()
|
||||
{
|
||||
local pcpu="$@"
|
||||
local ok=true
|
||||
|
||||
for p in $pcpu; do
|
||||
p=${p%%%*}
|
||||
if [ "$p" -ge "$PCPU_LIMIT" ]; then
|
||||
ok=false
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
[ "$ok" = "true" ] && PCPU_NFAIL=0
|
||||
[ "$ok" = "false" ] && PCPU_NFAIL=$((PCPU_NFAIL + 1))
|
||||
|
||||
[ "$PCPU_NFAIL" -ge "$PCPU_COUNT" ] && return 1
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
check_ubuscall()
|
||||
{
|
||||
local rv
|
||||
|
||||
ubus -t $UBUS_TIMEOUT call router.system info >/dev/null 2>&1
|
||||
rv=$?
|
||||
|
||||
[ "$rv" = "0" ] && return 0
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
main()
|
||||
{
|
||||
local topline nproc mem pcpu
|
||||
local restart_nproc restart_mem restart_pcpu
|
||||
local sample=1
|
||||
|
||||
while true ; do
|
||||
|
||||
# collect info
|
||||
topline=$(top -bn1 | grep "/sbin/[q]uestd" | grep -v monitor)
|
||||
|
||||
nproc=$(echo -n "$topline" | awk 'END{print NR}')
|
||||
check_nproc $nproc
|
||||
restart_nproc=$?
|
||||
|
||||
mem=$(echo -en "$topline" | awk '{print $5}')
|
||||
check_mem $mem
|
||||
restart_mem=$?
|
||||
|
||||
pcpu=$(echo -en "$topline" | awk '{print $7}')
|
||||
check_pcpu $pcpu
|
||||
restart_pcpu=$?
|
||||
|
||||
# do the restart
|
||||
if [ "$restart_nproc" = "1" -o \
|
||||
"$restart_mem" = "1" -o \
|
||||
"$restart_pcpu" = "1" ]
|
||||
then
|
||||
check_ubuscall || restart_questd
|
||||
fi
|
||||
|
||||
# sleep
|
||||
if [ "$sample" -lt "$SAMPLES" ]; then
|
||||
sample=$((sample + 1))
|
||||
sleep $SLEEP_SHORT
|
||||
else
|
||||
sample=1
|
||||
sleep $SLEEP_LONG
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
main $@
|
||||
@@ -3,14 +3,6 @@ config testserver '1'
|
||||
option port '1640'
|
||||
|
||||
config testserver '2'
|
||||
option server 'tptest.dataphone.se'
|
||||
option port '1640'
|
||||
|
||||
config testserver '3'
|
||||
option server 'referens.sth.ip-performance.se'
|
||||
option port '1642'
|
||||
|
||||
config testserver '4'
|
||||
option server 'tptest.songnetworks.se'
|
||||
option port '1640'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user