1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter.git synced 2025-03-09 15:40:20 +00:00

Fix RUTX support

This commit is contained in:
Ycarus (Yannick Chabanois) 2022-03-07 20:21:35 +01:00
parent 6fc4d11e09
commit 0b14e36374
98 changed files with 11611 additions and 893 deletions

View file

@ -1,174 +0,0 @@
#!/bin/sh
#
# Copyright (c) 2015 The Linux Foundation. All rights reserved.
# Copyright (c) 2011-2015 OpenWrt.org
#
. /lib/functions/uci-defaults.sh
. /lib/functions/system.sh
ipq40xx_setup_interfaces()
{
local board="$1"
case "$board" in
8dev,habanero-dvk|\
8dev,jalapeno|\
alfa-network,ap120c-ac|\
engenius,emr3500|\
engenius,ens620ext)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
;;
aruba,ap-303|\
aruba,ap-365|\
avm,fritzrepeater-1200|\
dlink,dap-2610 |\
engenius,eap1300|\
engenius,emd1|\
meraki,mr33|\
netgear,ex6100v2|\
netgear,ex6150v2|\
zyxel,wre6606)
ucidef_set_interface_lan "eth0"
;;
aruba,ap-303h|\
teltonika,rutx)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
ucidef_add_switch "switch0" \
"0u@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "0u@eth1" "5:wan"
;;
asus,map-ac2200|\
cilab,meshpoint-one|\
openmesh,a42|\
openmesh,a62)
ucidef_set_interfaces_lan_wan "eth1" "eth0"
;;
asus,rt-ac58u|\
p2w,r619ac-128m|\
p2w,r619ac|\
zyxel,nbg6617)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
ucidef_add_switch "switch0" \
"0u@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
;;
avm,fritzbox-4040|\
linksys,ea6350v3|\
linksys,ea8300)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
ucidef_add_switch "switch0" \
"0u@eth0" "1:lan" "2:lan" "3:lan" "4:lan"
;;
avm,fritzbox-7530)
ucidef_add_switch "switch0" \
"0u@eth0" "1:lan" "2:lan" "3:lan" "4:lan"
;;
avm,fritzrepeater-3000|\
compex,wpj419|\
compex,wpj428|\
engenius,eap2200)
ucidef_set_interface_lan "eth0 eth1"
;;
buffalo,wtr-m2133hp)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
ucidef_add_switch "switch0" \
"0u@eth0" "2:lan:3" "3:lan:2" "4:lan:1"
;;
cellc,rtl30vw)
ucidef_set_interface_lan "eth0"
ucidef_add_switch "switch0" \
"0u@eth0" "3:lan" "4:lan"
;;
ezviz,cs-w3-wd1200g-eup)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
ucidef_add_switch "switch0" \
"0u@eth0" "2:lan:3" "3:lan:2" "4:lan:1" "0u@eth1" "5:wan"
;;
glinet,gl-b1300 |\
glinet,gl-s1300)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
ucidef_add_switch "switch0" \
"0u@eth0" "3:lan" "4:lan"
;;
mobipromo,cm520-79f)
ucidef_add_switch "switch0" \
"0u@eth0" "3:lan:2" "4:lan:1"
ucidef_set_interface_wan "eth1"
;;
qxwlan,e2600ac-c1 |\
qxwlan,e2600ac-c2)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
ucidef_add_switch "switch0" \
"0u@eth0" "3:lan" "4:lan" "0u@eth1" "5:wan"
;;
unielec,u4019-32m)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
ucidef_add_switch "switch0" \
"0u@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "0u@eth1" "5:wan"
;;
*)
echo "Unsupported hardware. Network interfaces not initialized"
;;
esac
}
ipq40xx_setup_macs()
{
local board="$1"
local lan_mac=""
local wan_mac=""
local label_mac=""
case "$board" in
8dev,habanero-dvk)
label_mac=$(mtd_get_mac_binary "ART" 0x1006)
;;
asus,rt-ac58u|\
p2w,r619ac-128m|\
p2w,r619ac)
CI_UBIPART=UBI_DEV
wan_mac=$(mtd_get_mac_binary_ubi Factory 0x1006)
lan_mac=$(mtd_get_mac_binary_ubi Factory 0x5006)
label_mac=$wan_mac
;;
cilab,meshpoint-one)
label_mac=$(mtd_get_mac_binary "ART" 0x1006)
;;
dlink,dap-2610)
lan_mac=$(mtd_get_mac_ascii bdcfg lanmac)
label_mac=$lan_mac
;;
engenius,eap2200|\
engenius,emd1)
lan_mac=$(mtd_get_mac_ascii 0:APPSBLENV ethaddr)
label_mac=$lan_mac
;;
engenius,emr3500)
wan_mac=$(mtd_get_mac_ascii 0:APPSBLENV wanaddr)
lan_mac=$(mtd_get_mac_ascii 0:APPSBLENV ethaddr)
label_mac=$wan_mac
;;
engenius,ens620ext)
wan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
lan_mac=$(macaddr_add "$wan_mac" 1)
;;
ezviz,cs-w3-wd1200g-eup)
label_mac=$(mtd_get_mac_binary "ART" 0x6)
;;
linksys,ea6350v3)
wan_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr)
lan_mac=$(macaddr_add "$wan_mac" 1)
;;
esac
[ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
[ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
[ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
}
board_config_update
board=$(board_name)
ipq40xx_setup_interfaces $board
ipq40xx_setup_macs $board
board_config_flush
exit 0

View file

@ -0,0 +1,209 @@
#!/bin/sh
#
# Copyright (c) 2015 The Linux Foundation. All rights reserved.
# Copyright (c) 2011-2015 OpenWrt.org
#
. /lib/functions/uci-defaults.sh
. /lib/functions/teltonika-defaults.sh
. /lib/functions/system.sh
setup_json() {
local model="$1"
case "$model" in
RUTX08*)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
ucidef_add_switch "switch0" \
"0u@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "0u@eth1" "5:wan"
ucidef_set_hwinfo usb ethernet ios
;;
RUTX09*)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
ucidef_add_switch "switch0" \
"0u@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "0u@eth1" "5:wan"
ucidef_add_static_modem_info "$model" "3-1" "2" "gps_out"
ucidef_set_hwinfo dual_sim usb gps mobile ethernet ios
;;
RUTX10*)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
ucidef_add_switch "switch0" \
"0u@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "0u@eth1" "5:wan"
ucidef_set_hwinfo bluetooth usb wifi dual_band_ssid ethernet ios
;;
RUTX11*)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
ucidef_add_switch "switch0" \
"0u@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "0u@eth1" "5:wan"
ucidef_add_static_modem_info "$model" "3-1" "2" "gps_out"
ucidef_set_hwinfo dual_sim usb gps mobile wifi dual_band_ssid bluetooth ethernet ios
;;
RUTXR1*)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
ucidef_add_switch "switch0" \
"0u@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "0u@eth1" "5:wan"
ucidef_add_static_modem_info "$model" "3-1" "2"
ucidef_set_hwinfo dual_sim usb mobile wifi dual_band_ssid ethernet sfp_port
ucidef_set_release_version "2.3.1"
;;
RUTX12*)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
ucidef_add_switch "switch0" \
"0u@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "0u@eth1" "5:wan"
# builtin and primary should be first modem
ucidef_add_static_modem_info "$model" "3-1" "1" "primary" "gps_out"
ucidef_add_static_modem_info "$model" "1-1.2" "1"
ucidef_set_hwinfo usb gps mobile wifi dual_band_ssid bluetooth ethernet ios
ucidef_set_release_version "2.3.1"
;;
RUTX14*)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
ucidef_add_switch "switch0" \
"0u@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "0u@eth1" "5:wan"
ucidef_add_static_modem_info "$model" "1-1" "2" "gps_out"
ucidef_set_hwinfo usb gps dual_sim mobile wifi dual_band_ssid bluetooth ethernet ios at_sim
ucidef_set_release_version "2.6.1"
;;
RUTX18*)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
ucidef_add_switch "switch0" \
"0u@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "0u@eth1" "5:wan"
ucidef_add_static_modem_info "$model" "2-1" "2" "gps_out"
ucidef_set_hwinfo usb gps dual_sim mobile wifi dual_band_ssid bluetooth ethernet ios
;;
TRB2*)
ucidef_set_led_switch "lan" "LAN" "eth_led" "switch0" "0x04"
ucidef_set_interface_lan "eth0"
ucidef_add_static_modem_info "$model" "1-1.4" "2" "gps_out"
ucidef_add_serial_capabilities "rs232 rs485" \
"300 600 1200 2400 4800 9600 14400 19200 38400 56000 57600 115200 \
230400 460800 921600 1000000 3000000" \
"7 8"
ucidef_set_hwinfo dual_sim mobile gps ethernet ios
;;
RUT200* |\
RUT241*)
ucidef_set_led_switch "lan" "LAN" "eth1_led" "switch0" "0x2"
ucidef_set_led_switch "wan" "WAN" "eth2_led" "switch0" "0x1"
ucidef_add_switch "switch0" "1:lan" "0:wan" "6@eth0"
ucidef_set_interface_macaddr "lan" "$(mtd_get_mac_binary config 0x0)"
ucidef_set_interface_macaddr "wan" "$(macaddr_add "$(mtd_get_mac_binary config 0x0)" 1)"
ucidef_add_static_modem_info "$model" "1-1" "1"
[ "${model:7:1}" = "1" ] && ucidef_set_hwinfo mobile wifi \
ethernet || ucidef_set_hwinfo mobile wifi ethernet ios
;;
RUT2*)
ucidef_set_led_switch "lan" "LAN" "lan_led" "switch0" "0x04"
ucidef_set_led_netdev "wan" "WAN" "wan_led" "eth1"
ucidef_set_interfaces_lan_wan "eth0" "eth1"
ucidef_add_static_modem_info "$model" "1-1" "1"
[ "${model:6:1}" = "1" ] && ucidef_set_hwinfo mobile wifi \
ethernet || ucidef_set_hwinfo mobile wifi ethernet ios
;;
RUT300*)
ucidef_set_led_switch "lan1" "LAN1" "eth1_led" "switch0" "0x02"
ucidef_set_led_switch "lan2" "LAN2" "eth2_led" "switch0" "0x10"
ucidef_set_led_switch "lan3" "LAN3" "eth3_led" "switch0" "0x08"
ucidef_set_led_switch "lan4" "LAN4" "eth4_led" "switch0" "0x04"
ucidef_set_led_netdev "wan" "WAN" "wan_led" "eth1"
ucidef_set_interface_wan "eth1"
ucidef_add_switch "switch0" \
"0@eth0" "1:lan:1" "2:lan:4" "3:lan:3" "4:lan:2"
ucidef_set_hwinfo usb ethernet ios
;;
RUT360*)
ucidef_set_led_switch "lan" "LAN" "eth1_led" "switch0" "0x10"
ucidef_set_led_netdev "wan" "WAN" "eth2_led" "eth1"
ucidef_set_interfaces_lan_wan "eth0" "eth1"
ucidef_add_static_modem_info "$model" "1-1" "1"
ucidef_set_hwinfo mobile wifi dual_band_ssid ethernet ios
;;
RUT950*)
ucidef_set_led_switch "lan1" "LAN1" "eth1_led" "switch0" "0x10"
ucidef_set_led_switch "lan2" "LAN2" "eth2_led" "switch0" "0x08"
ucidef_set_led_switch "lan3" "LAN3" "eth3_led" "switch0" "0x04"
ucidef_set_led_netdev "wan" "WAN" "wan_led" "eth1"
ucidef_set_interface_wan "eth1"
ucidef_add_switch "switch0" "0@eth0" "2:lan:3" "3:lan:2" "4:lan:1"
ucidef_add_static_modem_info "$model" "1-1" "2"
[ "${model:7:2}" = "06" ] && ucidef_set_hwinfo dual_sim mobile \
wifi ethernet || ucidef_set_hwinfo dual_sim mobile wifi ethernet ios
;;
RUT955*)
ucidef_set_led_switch "lan1" "LAN1" "eth1_led" "switch0" "0x10"
ucidef_set_led_switch "lan2" "LAN2" "eth2_led" "switch0" "0x08"
ucidef_set_led_switch "lan3" "LAN3" "eth3_led" "switch0" "0x04"
ucidef_set_led_netdev "wan" "WAN" "wan_led" "eth1"
ucidef_set_interface_wan "eth1"
ucidef_add_switch "switch0" "0@eth0" "2:lan:3" "3:lan:2" "4:lan:1"
ucidef_add_static_modem_info "$model" "1-1.4" "2" "gps_out"
[ "${model:7:2}" = "06" ] && ucidef_set_hwinfo dual_sim usb gps \
mobile wifi ethernet || ucidef_set_hwinfo dual_sim usb gps \
mobile wifi ethernet ios
ucidef_add_serial_capabilities "rs232" \
"200 300 600 1200 1800 2400 4800 9600 19200 38400 57600 115200 \
230400 460800 500000 576000" \
"5 6 7 8"
ucidef_add_serial_capabilities "rs485" \
"300 600 1200 1800 2400 4800 9600 19200 38400 57600 115200 230400 \
460800 500000 576000 921600 1000000 1152000 1500000 2000000 \
2500000 3000000" \
"8"
;;
TRB140*)
ucidef_set_interface_lan "eth0 rndis0"
ucidef_add_trb14x_lte_modem "$model"
ucidef_add_nand_info "$model"
[ "${model:7:1}" = "2" ] && ucidef_set_hwinfo mobile ethernet || \
ucidef_set_hwinfo mobile ethernet ios
;;
TRB141*)
ucidef_set_interface_lan "rndis0"
ucidef_add_trb14x_lte_modem "$model"
ucidef_add_nand_info "$model"
ucidef_set_hwinfo mobile ios
;;
TRB142* |\
TRB145*)
ucidef_set_interface_lan "rndis0"
ucidef_add_trb14x_lte_modem "$model"
ucidef_add_nand_info "$model"
[ "${model:7:1}" = "2" ] && ucidef_set_hwinfo mobile || \
ucidef_set_hwinfo mobile ios
[ "${model:5:1}" = "2" ] && local rs="rs232"
ucidef_add_serial_capabilities "${rs:-rs485}" \
"300 600 1200 2400 4800 9600 19200 38400 57600 115200 460800" \
"5 6 7 8"
[ "${model:5:2}" = "23" -o "${model:5:2}" = "52" ] && \
ucidef_set_release_version "7.1"
;;
TCR100*)
ucidef_set_led_switch "lan" "LAN" "eth1_led" "switch0" "0x10"
ucidef_set_led_netdev "wan" "WAN" "eth2_led" "eth1"
ucidef_set_interfaces_lan_wan "eth0" "eth1"
ucidef_set_interface guest proto static type bridge \
guest 1 _wireless true _dhcp true
ucidef_add_static_modem_info "$model" "1-1" "1"
ucidef_set_hwinfo mobile wifi dual_band_ssid wps ethernet
;;
*)
echo "Unsupported hardware. Network interfaces not intialized"
;;
esac
}
#~ Get model name for RUTX products
if ! model="$(mnf_info --name)" 2>/dev/null; then
model="$(mnf_info --prod-code)" 2>/dev/null
fi
platform="$(cat /proc/device-tree/platform)" 2>/dev/null
board_config_update
setup_json "$model"
ucidef_set_board_platform "$platform"
board_config_flush
exit 0

View file

@ -0,0 +1,2 @@
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/mtdblock15 /log jffs2 defaults 0 0

View file

@ -1,246 +1,67 @@
#!/bin/sh
ath10kcal_die() {
echo "ath10cal: " "$*"
exit 1
}
ath10kcal_extract() {
local part=$1
local offset=$2
local count=$3
local mtd
mtd=$(find_mtd_chardev $part)
[ -n "$mtd" ] || \
ath10kcal_die "no mtd device found for partition $part"
dd if=$mtd of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count skip=$offset count=1 2>/dev/null || \
ath10kcal_die "failed to extract calibration data from $mtd"
}
ensure_correct_art() {
# NOTE(rytis): Hardcoded hashes for 64 KiB file, filled with zeroes (md5b0) and ones (md5b1).
local md5b0="fcd6bcb56c1689fcef28b57c22475bad"
local md5b1="ecb99e6ffea7be1e5419350f725da86b"
local artdir="/dev/mtd12"
local bindir="/usr/share/art/art_rutx.bin"
local md5art="$(md5sum $artdir)"
md5art="${md5art%% *}"
local devicename="$(mnf_info -n)"
devicename="${devicename:0:6}"
if [ "$devicename" != "RUTX08" ] && [ "$devicename" != "RUTX09" ]; then
if [ "$md5art" == "$md5b0" ] || [ "$md5art" == "$md5b1" ] && [ -e "$bindir" ]; then
mtd write $bindir $artdir
fi
else
if [ "$md5art" != "$md5b0" ] && [ "$md5art" != "$md5b1" ]; then
mtd erase $artdir
fi
fi
}
[ -e /lib/firmware/$FIRMWARE ] && exit 0
. /lib/functions/caldata.sh
. /lib/functions.sh
. /lib/functions/system.sh
board=$(board_name)
ensure_correct_art
case "$FIRMWARE" in
"ath10k/cal-pci-0000:01:00.0.bin")
case "$board" in
meraki,mr33)
caldata_extract_ubi "ART" 0x9000 0x844
caldata_valid "4408" || caldata_extract "ART" 0x9000 0x844
ath10k_patch_mac $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66) +1)
;;
esac
;;
"ath10k/pre-cal-pci-0000:01:00.0.bin")
case "$board" in
asus,map-ac2200)
caldata_extract_ubi "Factory" 0x9000 0x2f20
ln -sf /lib/firmware/ath10k/pre-cal-pci-0000\:00\:00.0.bin \
/lib/firmware/ath10k/QCA9888/hw2.0/board.bin
;;
avm,fritzrepeater-3000)
/usr/bin/fritz_cal_extract -i 1 -s 0x3D000 -e 0x212 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader0") || \
/usr/bin/fritz_cal_extract -i 1 -s 0x3C800 -e 0x212 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader0") || \
/usr/bin/fritz_cal_extract -i 1 -s 0x3C000 -e 0x212 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader0") || \
/usr/bin/fritz_cal_extract -i 1 -s 0x3D000 -e 0x212 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1") || \
/usr/bin/fritz_cal_extract -i 1 -s 0x3C800 -e 0x212 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1") || \
/usr/bin/fritz_cal_extract -i 1 -s 0x3C000 -e 0x212 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1")
;;
buffalo,wtr-m2133hp)
caldata_extract "ART" 0x9000 0x2f20
ath10k_patch_mac $(mtd_get_mac_binary ORGDATA 0x32)
;;
engenius,eap2200 |\
openmesh,a62)
caldata_extract "0:ART" 0x9000 0x2f20
;;
linksys,ea8300)
caldata_extract "ART" 0x9000 0x2f20
# OEM assigns 4 sequential MACs
ath10k_patch_mac $(macaddr_setbit_la $(macaddr_add "$(cat /sys/class/net/eth0/address)" 4))
;;
esac
;;
"ath10k/pre-cal-ahb-a000000.wifi.bin")
case "$board" in
8dev,habanero-dvk |\
8dev,jalapeno |\
alfa-network,ap120c-ac |\
cilab,meshpoint-one |\
ezviz,cs-w3-wd1200g-eup |\
glinet,gl-b1300 |\
glinet,gl-s1300 |\
linksys,ea6350v3 |\
mobipromo,cm520-79f |\
p2w,r619ac-128m |\
p2w,r619ac |\
qcom,ap-dk01.1-c1)
caldata_extract "ART" 0x1000 0x2f20
;;
aruba,ap-303 |\
aruba,ap-303h |\
aruba,ap-365)
caldata_extract "ART" 0x1000 0x2f20
ath10k_patch_mac $(mtd_get_mac_binary mfginfo 0x1D)
;;
asus,map-ac2200)
caldata_extract_ubi "Factory" 0x1000 0x2f20
;;
asus,rt-ac58u)
CI_UBIPART=UBI_DEV
caldata_extract_ubi "Factory" 0x1000 0x2f20
;;
avm,fritzbox-4040)
/usr/bin/fritz_cal_extract -i 1 -s 0x400 -e 0x207 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader_config")
;;
avm,fritzbox-7530 |\
avm,fritzrepeater-1200 |\
avm,fritzrepeater-3000)
/usr/bin/fritz_cal_extract -i 1 -s 0x3C000 -e 0x207 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader0") || \
/usr/bin/fritz_cal_extract -i 1 -s 0x3C800 -e 0x207 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader0") || \
/usr/bin/fritz_cal_extract -i 1 -s 0x3D000 -e 0x207 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader0") || \
/usr/bin/fritz_cal_extract -i 1 -s 0x3C000 -e 0x207 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1") || \
/usr/bin/fritz_cal_extract -i 1 -s 0x3C800 -e 0x207 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1") || \
/usr/bin/fritz_cal_extract -i 1 -s 0x3D000 -e 0x207 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1")
;;
buffalo,wtr-m2133hp)
caldata_extract "ART" 0x1000 0x2f20
ath10k_patch_mac $(mtd_get_mac_binary ORGDATA 0x26)
;;
cellc,rtl30vw |\
compex,wpj419 |\
compex,wpj428 |\
engenius,eap1300 |\
engenius,eap2200 |\
openmesh,a42 |\
openmesh,a62 |\
qxwlan,e2600ac-c1 |\
qxwlan,e2600ac-c2 |\
unielec,u4019-32m)
caldata_extract "0:ART" 0x1000 0x2f20
;;
dlink,dap-2610)
caldata_extract "ART" 0x1000 0x2f20
ath10k_patch_mac $(mtd_get_mac_ascii bdcfg wlanmac)
;;
engenius,emd1)
caldata_extract "0:ART" 0x1000 0x2f20
ath10k_patch_mac $(mtd_get_mac_ascii 0:APPSBLENV wlanaddr)
;;
engenius,emr3500)
caldata_extract "0:ART" 0x1000 0x2f20
ath10k_patch_mac $(mtd_get_mac_ascii 0:APPSBLENV ethaddr)
;;
engenius,ens620ext)
caldata_extract "ART" 0x1000 0x2f20
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) +2)
;;
linksys,ea8300)
caldata_extract "ART" 0x1000 0x2f20
ath10k_patch_mac $(macaddr_add "$(cat /sys/class/net/eth0/address)" 2)
;;
meraki,mr33)
caldata_extract_ubi "ART" 0x1000 0x2f20
caldata_valid "202f" || caldata_extract "ART" 0x1000 0x2f20
ath10k_patch_mac $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66) +2)
;;
netgear,ex6100v2 |\
netgear,ex6150v2)
caldata_extract "ART" 0x1000 0x2f20
ath10k_patch_mac $(mtd_get_mac_binary dnidata 0x0)
;;
teltonika,rutx)
caldata_extract "0:ART" 0x1000 0x2f20
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary "0:CONFIG" 0x0) 2)
;;
zyxel,nbg6617 |\
zyxel,wre6606)
caldata_extract "ART" 0x1000 0x2f20
ath10k_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -2)
ath10kcal_extract "0:ART" 4096 12064
;;
esac
;;
"ath10k/pre-cal-ahb-a800000.wifi.bin")
case "$board" in
8dev,habanero-dvk |\
8dev,jalapeno |\
alfa-network,ap120c-ac |\
cilab,meshpoint-one |\
ezviz,cs-w3-wd1200g-eup |\
glinet,gl-b1300 |\
glinet,gl-s1300 |\
linksys,ea6350v3 |\
mobipromo,cm520-79f |\
p2w,r619ac-128m |\
p2w,r619ac |\
qcom,ap-dk01.1-c1)
caldata_extract "ART" 0x5000 0x2f20
;;
aruba,ap-303 |\
aruba,ap-303h |\
aruba,ap-365)
caldata_extract "ART" 0x5000 0x2f20
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary mfginfo 0x1D) +1)
;;
asus,map-ac2200)
caldata_extract_ubi "Factory" 0x5000 0x2f20
;;
asus,rt-ac58u)
CI_UBIPART=UBI_DEV
caldata_extract_ubi "Factory" 0x5000 0x2f20
;;
avm,fritzbox-4040)
/usr/bin/fritz_cal_extract -i 1 -s 0x400 -e 0x208 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader_config")
;;
avm,fritzbox-7530 |\
avm,fritzrepeater-1200 |\
avm,fritzrepeater-3000)
/usr/bin/fritz_cal_extract -i 1 -s 0x3C800 -e 0x208 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader0") || \
/usr/bin/fritz_cal_extract -i 1 -s 0x3D000 -e 0x208 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader0") || \
/usr/bin/fritz_cal_extract -i 1 -s 0x3C000 -e 0x208 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader0") || \
/usr/bin/fritz_cal_extract -i 1 -s 0x3C800 -e 0x208 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1") || \
/usr/bin/fritz_cal_extract -i 1 -s 0x3D000 -e 0x208 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1") || \
/usr/bin/fritz_cal_extract -i 1 -s 0x3C000 -e 0x208 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1")
;;
buffalo,wtr-m2133hp)
caldata_extract "ART" 0x5000 0x2f20
ath10k_patch_mac $(mtd_get_mac_binary ORGDATA 0x2c)
;;
cellc,rtl30vw |\
compex,wpj419 |\
compex,wpj428 |\
engenius,eap1300 |\
engenius,eap2200 |\
openmesh,a42 |\
openmesh,a62 |\
qxwlan,e2600ac-c1 |\
qxwlan,e2600ac-c2 |\
unielec,u4019-32m)
caldata_extract "0:ART" 0x5000 0x2f20
;;
dlink,dap-2610)
caldata_extract "ART" 0x5000 0x2f20
ath10k_patch_mac $(mtd_get_mac_ascii bdcfg wlanmac_a)
;;
engenius,emd1)
caldata_extract "0:ART" 0x5000 0x2f20
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii 0:APPSBLENV wlanaddr) +1)
;;
engenius,emr3500)
caldata_extract "0:ART" 0x5000 0x2f20
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii 0:APPSBLENV ethaddr) +1)
;;
engenius,ens620ext)
caldata_extract "ART" 0x5000 0x2f20
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) +3)
;;
linksys,ea8300)
caldata_extract "ART" 0x5000 0x2f20
ath10k_patch_mac $(macaddr_add "$(cat /sys/class/net/eth0/address)" 3)
;;
meraki,mr33)
caldata_extract_ubi "ART" 0x5000 0x2f20
caldata_valid "202f" || caldata_extract "ART" 0x5000 0x2f20
ath10k_patch_mac $(macaddr_add $(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66) +3)
;;
netgear,ex6100v2 |\
netgear,ex6150v2)
caldata_extract "ART" 0x5000 0x2f20
ath10k_patch_mac $(mtd_get_mac_binary dnidata 0xc)
;;
teltonika,rutx)
caldata_extract "0:ART" 0x1000 0x2f20
ath10k_patch_mac $(macaddr_add $(mtd_get_mac_binary "0:CONFIG" 0x0) 3)
;;
zyxel,nbg6617 |\
zyxel,wre6606)
caldata_extract "ART" 0x5000 0x2f20
ath10k_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -1)
ath10kcal_extract "0:ART" 20480 12064
;;
esac
;;

View file

@ -0,0 +1,23 @@
#!/bin/ash
[ "$ACTION" == "add" ] || exit 0
PHYNBR=${DEVPATH##*/phy}
[ -n $PHYNBR ] || exit 0
. /lib/functions.sh
. /lib/functions/system.sh
board=$(board_name)
case "$board" in
teltonika,rutx)
mac_addr=$(mtd_get_mac_binary 0:CONFIG 0)
if [ "$mac_addr" != "ff:ff:ff:ff:ff:ff" ]; then
echo $(macaddr_add $mac_addr $(($PHYNBR + 2)) ) > /sys${DEVPATH}/macaddress
fi
;;
*)
;;
esac

View file

@ -0,0 +1,70 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2006-2011 OpenWrt.org
START=10
STOP=90
uci_apply_defaults() {
. /lib/functions/system.sh
cd /etc/uci-defaults || return 0
files="$(find . -type f | sort)"
[ -z "$files" ] && return 0
mkdir -p /tmp/.uci
for file in $files; do
( . "./$file" ) && rm -f "$file"
done
uci commit
}
boot() {
[ -f /proc/mounts ] || /sbin/mount_root
[ -f /proc/jffs2_bbc ] && echo "S" > /proc/jffs2_bbc
mkdir -p /var/run
mkdir -p /var/log
mkdir -p /var/lock
mkdir -p /var/state
mkdir -p /var/tmp
mkdir -p /tmp/.uci
chmod 0700 /tmp/.uci
touch /var/log/wtmp
touch /var/log/lastlog
mkdir -p /tmp/resolv.conf.d
touch /tmp/resolv.conf.d/resolv.conf.auto
ln -sf /tmp/resolv.conf.d/resolv.conf.auto /tmp/resolv.conf
grep -q debugfs /proc/filesystems && /bin/mount -o noatime -t debugfs debugfs /sys/kernel/debug
grep -q bpf /proc/filesystems && /bin/mount -o nosuid,nodev,noexec,noatime,mode=0700 -t bpf bpffs /sys/fs/bpf
grep -q pstore /proc/filesystems && /bin/mount -o noatime -t pstore pstore /sys/fs/pstore
# mount all entries in fstab
/bin/mount -a &
# /log directory might be created on preinit
# symlink /storage to /log on TRB14X devices
[ -d /storage -a ! -h /log ] && {
rm -rf /log
ln -sf /storage /log
}
# Wifi ---
param=$(/sbin/mnf_info "--name")
router_name=${param:0:6}
if [ $router_name == "RUTX08" ] || [ $router_name == "RUTX09" ]; then
rm /etc/modules.d/ath10k
fi
/bin/board_detect
/sbin/kmodloader
/bin/config_generate
uci_apply_defaults
[ -f "/etc/config/teltonika" ] && rm /etc/config/teltonika
# temporary hack until configd exists
/sbin/reload_config
# leave finished boot script indication
touch /var/run/boot-done
}

View file

@ -0,0 +1,13 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org
START=95
boot() {
mount_root done
rm -f /sysupgrade.tgz && sync
# process user commands
[ -f /etc/rc.local ] && {
sh /etc/rc.local
}
}

View file

@ -0,0 +1,66 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2015 OpenWrt.org
START=94
STOP=10
USE_PROCD=1
load_gpio_switch()
{
local name
local gpio_pin
local value
config_get gpio_pin "$1" gpio_pin
config_get name "$1" name
config_get value "$1" value 0
[ -z "$gpio_pin" ] && {
echo >&2 "Skipping gpio_switch '$name' due to missing gpio_pin"
return 1
}
local gpio_path
if [ -n "$(echo "$gpio_pin" | grep -E "^[0-9]+$")" ]; then
gpio_path="/sys/class/gpio/gpio${gpio_pin}"
# export GPIO pin for access
[ -d "$gpio_path" ] || {
echo "$gpio_pin" >/sys/class/gpio/export
# we need to wait a bit until the GPIO appears
[ -d "$gpio_path" ] || sleep 1
}
# direction attribute only exists if the kernel supports changing the
# direction of a GPIO
if [ -e "${gpio_path}/direction" ]; then
# set the pin to output with high or low pin value
{ [ "$value" = "0" ] && echo "low" || echo "high"; } \
>"$gpio_path/direction"
else
{ [ "$value" = "0" ] && echo "0" || echo "1"; } \
>"$gpio_path/value"
fi
else
gpio_path="/sys/class/gpio/${gpio_pin}"
[ -d "$gpio_path" ] && {
{ [ "$value" = "0" ] && echo "0" || echo "1"; } \
>"$gpio_path/value"
}
fi
}
service_triggers()
{
procd_add_reload_trigger "system"
}
start_service()
{
[ -e /sys/class/gpio/ ] && {
config_load system
config_foreach load_gpio_switch gpio_switch
}
}

View file

@ -0,0 +1,140 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2008 OpenWrt.org
START=96
load_led() {
local name
local sysfs
local trigger
local dev
local ports
local mode
local default
local delayon
local delayoff
local interval
config_get sysfs $1 sysfs
config_get name $1 name "$sysfs"
config_get trigger $1 trigger "none"
config_get dev $1 dev
config_get ports $1 port
config_get mode $1 mode
config_get_bool default $1 default "0"
config_get delayon $1 delayon
config_get delayoff $1 delayoff
config_get interval $1 interval "50"
config_get port_state $1 port_state
config_get delay $1 delay "150"
config_get message $1 message ""
config_get gpio $1 gpio "0"
config_get inverted $1 inverted "0"
if [ "$trigger" = "rssi" ]; then
# handled by rssileds userspace process
return
fi
[ "$trigger" = "usbdev" ] && {
# Backward compatibility: translate to the new trigger
trigger="usbport"
# Translate port of root hub, e.g. 4-1 -> usb4-port1
ports=$(echo "$dev" | sed -n 's/^\([0-9]*\)-\([0-9]*\)$/usb\1-port\2/p')
# Translate port of extra hub, e.g. 2-2.4 -> 2-2-port4
[ -z "$ports" ] && ports=$(echo "$dev" | sed -n 's/\./-port/p')
}
[ -e /sys/class/leds/${sysfs}/brightness ] && {
echo "setting up led ${name}"
printf "%s %s %d\n" \
"$sysfs" \
"$(sed -ne 's/^.*\[\(.*\)\].*$/\1/p' /sys/class/leds/${sysfs}/trigger)" \
"$(cat /sys/class/leds/${sysfs}/brightness)" \
>> /var/run/led.state
[ "$default" = 0 ] &&
echo 0 >/sys/class/leds/${sysfs}/brightness
echo $trigger > /sys/class/leds/${sysfs}/trigger 2> /dev/null
ret="$?"
[ $default = 1 ] &&
cat /sys/class/leds/${sysfs}/max_brightness > /sys/class/leds/${sysfs}/brightness
[ $ret = 0 ] || {
echo >&2 "Skipping trigger '$trigger' for led '$name' due to missing kernel module"
return 1
}
case "$trigger" in
"netdev")
[ -n "$dev" ] && {
echo $dev > /sys/class/leds/${sysfs}/device_name
for m in $mode; do
[ -e "/sys/class/leds/${sysfs}/$m" ] && \
echo 1 > /sys/class/leds/${sysfs}/$m
done
echo $interval > /sys/class/leds/${sysfs}/interval
}
;;
"timer"|"oneshot")
[ -n "$delayon" ] && \
echo $delayon > /sys/class/leds/${sysfs}/delay_on
[ -n "$delayoff" ] && \
echo $delayoff > /sys/class/leds/${sysfs}/delay_off
;;
"usbport")
local p
for p in $ports; do
echo 1 > /sys/class/leds/${sysfs}/ports/$p
done
;;
"port_state")
[ -n "$port_state" ] && \
echo $port_state > /sys/class/leds/${sysfs}/port_state
;;
"gpio")
echo $gpio > /sys/class/leds/${sysfs}/gpio
echo $inverted > /sys/class/leds/${sysfs}/inverted
;;
switch[0-9]*)
local port_mask speed_mask
config_get port_mask $1 port_mask
[ -n "$port_mask" ] && \
echo $port_mask > /sys/class/leds/${sysfs}/port_mask
config_get speed_mask $1 speed_mask
[ -n "$speed_mask" ] && \
echo $speed_mask > /sys/class/leds/${sysfs}/speed_mask
[ -n "$mode" ] && \
echo "$mode" > /sys/class/leds/${sysfs}/mode
;;
esac
}
}
start() {
[ -e /sys/class/leds/ ] && {
[ -s /var/run/led.state ] && {
local led trigger brightness
while read led trigger brightness; do
[ -e "/sys/class/leds/$led/trigger" ] && \
echo "$trigger" > "/sys/class/leds/$led/trigger"
[ -e "/sys/class/leds/$led/brightness" ] && \
echo "$brightness" > "/sys/class/leds/$led/brightness"
done < /var/run/led.state
rm /var/run/led.state
}
config_load system
config_foreach load_led led
}
}

View file

@ -0,0 +1,39 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2021 Teltonika Networks
START=96
USE_PROCD=1
PROG=/bin/board_track
NAME=board_track
PIDCOUNT=1
start_service() {
config_load system
config_get modem_track system modem_track 1
[ "$modem_track" != 0 ] || return
local pid_file="/var/run/${NAME}.${PIDCOUNT}.pid"
procd_open_instance
procd_set_param command "$PROG"
procd_set_param file /etc/config/system
procd_set_param respawn
procd_set_param stdout 1
procd_set_param pidfile $pid_file
procd_close_instance
}
reload_service() {
stop
start
}
service_triggers() {
procd_add_reload_trigger "system"
}

View file

@ -0,0 +1,29 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2006-2011 OpenWrt.org
START=10
STOP=90
NAND_PART="nand_ubi"
boot() {
# check if spi-nand is present
local mtd=$(grep -i -m 1 "$NAND_PART" /proc/mtd | cut -c 4- | cut -d ':' -f1)
[ -z "$mtd" ] && {
return 0
}
[ ! -e /nand_storage ] && {
mkdir /nand_storage
}
# attach mtd device, automatically format if empty
ubiattach /dev/ubi_ctrl -m "$mtd"
# create default volume, if volume not present
[ ! -e /dev/ubi0_0 ] && {
ubimkvol /dev/ubi0 -m -N nand_storage
}
mount -t ubifs -o sync,noatime,rw ubi0:nand_storage /nand_storage/
}

View file

@ -0,0 +1,28 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2021 Teltonika
START=50
STOP=51
USE_PROCD=1
service_triggers()
{
procd_add_reload_trigger "ntpserver"
}
start_service() {
. /lib/functions.sh
local enabled
config_load ntpserver
config_get enabled general enabled "0"
[ "$enabled" -gt 0 ] || return
logger -t "ntpd" "Starting NTP server"
procd_open_instance
procd_set_param respawn 0
procd_set_param command "ntpd" -ln
procd_close_instance
}

View file

@ -0,0 +1,30 @@
#!/bin/sh /etc/rc.common
# (C) 2013 openwrt.org
START=81
boot() {
SHA_ALGS="sha1-neon sha224-neon sha256-neon sha384-neon sha512-neon md5-generic"
for alg in $SHA_ALGS; do
crconf add driver "authenc(hmac($alg),cbc(aes-generic))" type 3
crconf add driver "pcrypt(authenc(hmac($alg),cbc(aes-generic)))" type 3
done
for alg in $SHA_ALGS; do
crconf add driver "authenc(hmac($alg),cbc(des3_ede-generic))" type 3
crconf add driver "pcrypt(authenc(hmac($alg),cbc(des3_ede-generic)))" type 3
done
}
start() {
return 0
}
restart() {
return 0
}
stop() {
return 0
}

View file

@ -0,0 +1,32 @@
#!/bin/sh /etc/rc.common
START=98
ipq40xx_power_auto() {
# change scaling governor as ondemand to enable clock scaling based on system load
echo "performance" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
# set scaling min freq as 200 MHz
echo "716000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
# Change sampling rate for frequency scaling decisions to 1s, from 10 ms
#echo "1000000" > /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate
# Change sampling rate for frequency down scaling decision to 10s
#echo 10 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor
# Change the CPU load threshold above which frequency is up-scaled to
# turbo frequency,to 50%
#echo 50 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
}
start() {
. /lib/functions.sh
local board=$(board_name)
case "$board" in
teltonika,rutx | ap-dk01.1-c1 | ap-dk01.1-c2 | ap-dk04.1-c1 | ap-dk04.1-c2 | ap-dk04.1-c3 | \
ap-dk04.1-c4 | ap-dk04.1-c5 | ap-dk05.1-c1 | ap-dk06.1-c1 | ap-dk07.1-c1 | ap-dk07.1-c2 | ap-dk07.1-c3)
ipq40xx_power_auto ;;
esac
}

View file

@ -0,0 +1,46 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org
START=11
apply_defaults() {
local mem="$(awk '/^MemTotal:/ {print $2}' /proc/meminfo)"
local min_free frag_low_thresh frag_high_thresh
if [ "$mem" -gt 65536 ]; then # 128M
min_free=16384
elif [ "$mem" -gt 32768 ]; then # 64M
#Too high for RUT3 device, lets make 2048
#min_free=8192
min_free=2048
else
min_free=1024
frag_low_thresh=393216
frag_high_thresh=524288
fi
sysctl -qw vm.min_free_kbytes="$min_free"
[ "$frag_low_thresh" ] && sysctl -qw \
net.ipv4.ipfrag_low_thresh="$frag_low_thresh" \
net.ipv4.ipfrag_high_thresh="$frag_high_thresh" \
net.ipv6.ip6frag_low_thresh="$frag_low_thresh" \
net.ipv6.ip6frag_high_thresh="$frag_high_thresh" \
net.netfilter.nf_conntrack_frag6_low_thresh="$frag_low_thresh" \
net.netfilter.nf_conntrack_frag6_high_thresh="$frag_high_thresh"
# first set default, then all interfaces to avoid races with appearing interfaces
if [ -d /proc/sys/net/ipv6/conf ]; then
echo 0 > /proc/sys/net/ipv6/conf/default/accept_ra
for iface in /proc/sys/net/ipv6/conf/*/accept_ra; do
echo 0 > "$iface"
done
fi
}
start() {
apply_defaults
for CONF in /etc/sysctl.d/*.conf /etc/sysctl.conf; do
[ -f "$CONF" ] && sysctl -e -p "$CONF" >&-
done
}

View file

@ -0,0 +1,34 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2013-2014 OpenWrt.org
START=00
STOP=90
RTC_DEV=/dev/rtc0
HWCLOCK=/sbin/hwclock
boot() {
# start && exit 0
local maxtime="$(maxtime)"
local curtime="$(date +%s)"
[ $curtime -lt $maxtime ] && date -s @$maxtime
}
start() {
boot
}
stop() {
[ -e "$RTC_DEV" ] && [ -e "$HWCLOCK" ] && $HWCLOCK -w -u -f $RTC_DEV && \
logger -t sysfixtime "saved '$(date)' to $RTC_DEV"
}
maxtime() {
local file newest
for file in $( find /etc -type f ) ; do
[ -z "$newest" -o "$newest" -ot "$file" ] && newest=$file
done
[ "$newest" ] && date -r "$newest" +%s
}

View file

@ -0,0 +1,45 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2014 OpenWrt.org
START=10
USE_PROCD=1
validate_system_section() {
uci_load_validate system system "$1" "$2" \
'hostname:string:%%NAME%%' \
'conloglevel:uinteger' \
'buffersize:uinteger' \
'timezone:string:UTC' \
'zonename:string'
}
system_config() {
[ "$2" = 0 ] || {
echo "validation failed"
return 1
}
echo "$hostname" > /proc/sys/kernel/hostname
[ -z "$conloglevel" -a -z "$buffersize" ] || dmesg ${conloglevel:+-n $conloglevel} ${buffersize:+-s $buffersize}
echo "$timezone" > /tmp/TZ
[ -n "$zonename" ] && [ -f "/usr/share/zoneinfo/${zonename// /_}" ] \
&& ln -sf "/usr/share/zoneinfo/${zonename// /_}" /tmp/localtime \
&& rm -f /tmp/TZ
# apply timezone to kernel
hwclock -u --systz
}
reload_service() {
config_load system
config_foreach validate_system_section system system_config
}
service_triggers() {
procd_add_reload_trigger "system"
procd_add_validation validate_system_section
}
start_service() {
reload_service
}

View file

@ -0,0 +1,13 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org
STOP=90
restart() {
:
}
stop() {
sync
/bin/umount -a -d -r
}

View file

@ -0,0 +1,26 @@
#!/bin/sh
SECTION="hwinfo"
CONFIG="hwinfo"
get_hw_info() {
param=$(/sbin/mnf_info "--name")
[ -n "$param" -a ${#param} == 12 ] && uci set "system"."@system[0]"."device_code"=$param
hostname=${param:0:6}
[ -n "$hostname" -a ${#hostname} == 6 -a -z "$(uci -q get system.@system[0].hostname)" ] && uci set "system"."@system[0]"."hostname"=Teltonika-$hostname.com
routername=${param:0:6}
[ -n "$routername" -a ${#routername} == 6 -a -z "$(uci -q get system.@system[0].routername)" ] && uci set "system"."@system[0]"."routername"=$routername
version=$(cat /etc/version)
[ -n "$version" ] && uci set "system"."@system[0]"."device_fw_version"=$version
uci commit "system"
}
# get device information
echo "Reading device information"
get_hw_info
exit 0

View file

@ -0,0 +1,28 @@
#!/bin/sh
. /lib/functions.sh
. /lib/functions/board.sh
set_pin() {
local sim="$1"
local modem position num builtin
config_get modem "$sim" modem
builtin=$(is_builtin_modem "$modem")
[ "$builtin" = "0" ] && return
config_get position "$sim" position
#If modem builtin and primary then position num 3 or 4 else 1 or 2
[ "$builtin" = "2" ] && num=$((position + 2)) || num=$position
pin=`/sbin/mnf_info --simpin $num`
[ -z "$pin" ] && return
uci -q set "simcard"."$sim"."pincode"="$pin"
}
config_load simcard
config_foreach set_pin sim
uci commit simcard
exit 0

View file

@ -0,0 +1,119 @@
#!/bin/sh
. /lib/functions.sh
CONFIG="widget"
MOBILE_CONFIG="/etc/config/simcard"
RMS_CONFIG="/etc/config/rms_connect_mqtt"
WIFI_CONFIG="/etc/config/wireless"
ETHERNET=$(uci -q get network.@switch[0].name)
ethernet_widget_exists=0
mobile_widget_exists=0
system_widget_exists=0
wifi_widget_exists=0
rms_widget_exists=0
position=1
radio0_network=1
radio1_network=1
check_for_widgets() {
local widget="$1"
local type
config_get type "$widget" type
if [ "$type" = "ethernet" ]; then
ethernet_widget_exists=1
elif [ "$type" = "mobile" ]; then
mobile_widget_exists=1
elif [ "$type" = "system" ]; then
system_widget_exists=1
elif [ "$type" = "wifi" ]; then
wifi_widget_exists=1
elif [ "$type" = "rms" ]; then
rms_widget_exists=1
fi
}
setup_wifi_fields() {
local iface_section="$1"
local device
config_get device "$iface_section" device
section=$(uci -q add widget widget)
if [ "$device" == "radio0" ]; then
uci -q set $CONFIG."${section}.id"=$device."network${radio0_network}"
let "radio0_network=radio0_network + 1"
elif [ "$device" == "radio1" ]; then
uci -q set $CONFIG."${section}.id"=$device."network${radio1_network}"
let "radio1_network=radio1_network + 1"
fi
uci -q set $CONFIG."${section}.type=wifi"
uci -q set $CONFIG."${section}.position=${position}"
uci -q set $CONFIG."${section}.enabled=1"
let "position=position + 1"
}
check_if_config_exists() {
if [ ! -f "/etc/config/${CONFIG}" ]; then
touch "/etc/config/${CONFIG}"
fi
}
setup_side_widget() {
config_load widget
config_foreach check_for_widgets widget
if [ $ethernet_widget_exists -eq 0 -a -n "$ETHERNET" ]; then
check_if_config_exists
section=$(uci -q add widget widget)
uci -q set $CONFIG."${section}.id=widget1"
uci -q set $CONFIG."${section}.type=ethernet"
uci -q set $CONFIG."${section}.position=${position}"
uci -q set $CONFIG."${section}.enabled=1"
let "position=position + 1"
fi
if [ $mobile_widget_exists -eq 0 -a -s "$MOBILE_CONFIG" -a -f "$MOBILE_CONFIG" ]; then
check_if_config_exists
modem_count=$(jsonfilter -q -i /etc/board.json -e '@["modems"][*]' | wc -l)
for i in $(seq $modem_count)
do
section=$(uci -q add widget widget)
uci -q set $CONFIG."${section}.id=mobile-widget$i"
uci -q set $CONFIG."${section}.type=mobile"
uci -q set $CONFIG."${section}.position=${position}"
uci -q set $CONFIG."${section}.enabled=1"
let "position=position + 1"
done
fi
if [ $system_widget_exists -eq 0 ]; then
check_if_config_exists
section=$(uci -q add widget widget)
uci -q set $CONFIG."${section}.id=widget3"
uci -q set $CONFIG."${section}.type=system"
uci -q set $CONFIG."${section}.position=${position}"
uci -q set $CONFIG."${section}.enabled=1"
let "position=position + 1"
fi
if [ $wifi_widget_exists -eq 0 -a -f "$WIFI_CONFIG" ]; then
check_if_config_exists
config_load wireless
config_foreach setup_wifi_fields wifi-iface
fi
if [ $rms_widget_exists -eq 0 -a -f "$RMS_CONFIG" ]; then
check_if_config_exists
section=$(uci -q add widget widget)
uci -q set $CONFIG."${section}.id=widget5"
uci -q set $CONFIG."${section}.type=rms"
uci -q set $CONFIG."${section}.position=${position}"
uci -q set $CONFIG."${section}.enabled=1"
let "position=position + 1"
fi
uci -q commit $CONFIG
}
setup_side_widget
exit 0

View file

@ -0,0 +1,34 @@
#!/bin/sh
. /lib/functions.sh
move_network(){
local section=$1
local device ports vlan
config_get ports "$section" ports
config_get device "$section" device
config_get vlan "$section" vlan
[ "$vlan" -eq 1 ] && {
if list_contains "ports" "0t" && list_contains "ports" "5"; then
uci_set network "$section" ports "${ports/0t/0}"
uci_set network "$section" vlan "2"
uci_remove network "$section" vid
fi
}
[ "$vlan" -eq 2 ] && {
if list_contains ports "0t"; then
echo "Contains"
uci_set network "$section" ports "${ports/0t/0}"
uci_set network "$section" vlan "1"
uci_remove network "$section" vid
fi
}
}
config_load network
config_foreach move_network switch_vlan
uci_commit network
exit 0

View file

@ -0,0 +1,16 @@
#!/bin/sh
[ -n "$(uci -q get system.modem.disable)" ] || {
for m in /sys/class/gpio/modem*_power; do
local label="$(basename $m | awk -F_ '{print $1}')"
uci set "system.${label}=mctl"
uci set "system.${label}.disable=0"
# modem is turned on in preinit but others are not
[ "${label}" != "modem" ] && /sbin/mctl -p -m "${label}"
done
uci commit system
}
exit 0

View file

@ -0,0 +1,35 @@
#!/bin/sh
. /lib/functions.sh
CONFIG="/etc/config/user_groups"
migrate_tel_list() {
local tel="$1"
local new_section="$2"
uci -q add_list user_groups."$new_section".tel="$tel"
}
migrate_group() {
local group="$1"
local name
config_get name "$group" name ""
local new_section=`uci -q add user_groups phone`
uci -q set user_groups."$new_section".name="$name"
config_list_foreach "$group" tel migrate_tel_list "$new_section"
uci -q delete sms_utils."$group"
}
if [ ! -e "$CONFIG" ]; then
touch "$CONFIG"
fi
config_load sms_utils
config_foreach migrate_group group
uci -q commit user_groups
uci -q commit sms_utils
exit 0

View file

@ -0,0 +1,140 @@
#!/bin/sh
[ -e /etc/config/strongswan ] || exit 0
. /lib/functions.sh
ENABLED=0
move_config() {
local name=$1
#get old config
config_get_bool enabled "$1" "enabled" "0"
config_get keyexchange "$1" "keyexchange"
config_get aggressive "$1" "aggressive"
config_get ipsec_type "$1" "ipsec_type"
config_get my_identifier_type "$1" "my_identifier_type"
config_get my_identifier "$1" "my_identifier"
config_get leftfirewall "$1" "leftfirewall"
config_get forceencaps "$1" "forceencaps"
config_get dpdaction "$1" "dpdaction" "none"
config_get dpddelay "$1" "dpddelay"
config_get dpdtimeout "$1" "dpdtimeout"
config_get psk_key "$1" "psk_key"
config_get right "$1" "right"
config_get rightfirewall "$1" "rightfirewall"
config_get ike_encryption_algorithm "$1" "ike_encryption_algorithm"
config_get ike_authentication_algorithm "$1" "ike_authentication_algorithm"
config_get ike_dh_group "$1" "ike_dh_group"
config_get ikelifetime "$1" "ikelifetime"
config_get esp_encryption_algorithm "$1" "esp_encryption_algorithm"
config_get esp_hash_algorithm "$1" "esp_hash_algorithm"
config_get esp_pfs_group "$1" "esp_pfs_group"
config_get keylife "$1" "keylife"
config_get leftsubnet "$1" "leftsubnet"
config_get rightsubnet "$1" "rightsubnet"
config_get leftprotoport "$1" "leftprotoport"
config_get rightprotoport "$1" "rightprotoport"
[ "$enabled" = 1 ] && ENABLED=1
#set new config structure
config_set
uci_add "ipsec" "proposal" "${name}_ph1"
uci_set "ipsec" $CONFIG_SECTION "encryption_algorithm" "$ike_encryption_algorithm"
uci_set "ipsec" $CONFIG_SECTION "hash_algorithm" "$ike_authentication_algorithm"
uci_set "ipsec" $CONFIG_SECTION "dh_group" "$ike_dh_group"
uci_add "ipsec" "proposal" "${name}_ph2"
uci_set "ipsec" $CONFIG_SECTION "encryption_algorithm" "$esp_encryption_algorithm"
uci_set "ipsec" $CONFIG_SECTION "hash_algorithm" "$esp_hash_algorithm"
uci_set "ipsec" $CONFIG_SECTION "dh_group" "$esp_pfs_group"
uci_add "ipsec" "connection" "${name}_c"
uci_set "ipsec" $CONFIG_SECTION "mode" "start"
uci_set "ipsec" $CONFIG_SECTION "type" "$ipsec_type"
uci_set "ipsec" $CONFIG_SECTION "local_subnet" "$leftsubnet"
uci_set "ipsec" $CONFIG_SECTION "remote_subnet" "$rightsubnet"
uci_set "ipsec" $CONFIG_SECTION "remote_firewall" "$rightfirewall"
uci_set "ipsec" $CONFIG_SECTION "keyexchange" "$keyexchange"
uci_set "ipsec" $CONFIG_SECTION "aggressive" "$aggressive"
uci_set "ipsec" $CONFIG_SECTION "ikelifetime" "$ikelifetime"
uci_set "ipsec" $CONFIG_SECTION "lifetime" "$lifetime"
[ -n "$dpdaction" ] && {
uci_set "ipsec" $CONFIG_SECTION "_dpd" "1"
uci_set "ipsec" $CONFIG_SECTION "dpdaction" "$dpdaction"
uci_set "ipsec" $CONFIG_SECTION "dpddelay" "$dpddelay"
}
uci_set "ipsec" $CONFIG_SECTION "crypto_proposal" "${name}_ph2"
uci_set "ipsec" $CONFIG_SECTION "leftprotoport" "$leftprotoport"
uci_set "ipsec" $CONFIG_SECTION "rightprotoport" "$rightprotoport"
uci_set "ipsec" $CONFIG_SECTION "lifetime" "$keylife"
uci_set "ipsec" $CONFIG_SECTION "forceencaps" "$forceencaps"
uci_add "ipsec" "remote" "${name}"
uci_set "ipsec" $CONFIG_SECTION "enabled" "$enabled"
uci_set "ipsec" $CONFIG_SECTION "gateway" "$right"
uci_set "ipsec" $CONFIG_SECTION "remote_identifier" "%any"
uci_set "ipsec" $CONFIG_SECTION "authentication_method" "psk"
uci_set "ipsec" $CONFIG_SECTION "pre_shared_key" "$psk_key"
uci_set "ipsec" $CONFIG_SECTION "local_identifier" "$my_identifier"
uci_set "ipsec" $CONFIG_SECTION "crypto_proposal" "${name}_ph1"
[ "$ipsec_type" = "tunnel" ] && uci -q add_list "ipsec"."${CONFIG_SECTION}"."tunnel"="${name}_c"
[ "$ipsec_type" = "transport" ] && uci -q add_list "ipsec"."${CONFIG_SECTION}"."transport"="${name}_c"
uci_commit "ipsec"
}
config_load 'strongswan'
config_foreach move_config 'conn'
[ "$ENABLED" = 1 ] && {
uci_add firewall rule
uci_set firewall "$CONFIG_SECTION" src 'wan'
uci_set firewall "$CONFIG_SECTION" name 'Allow-IPsec-ESP'
uci_set firewall "$CONFIG_SECTION" target 'ACCEPT'
uci_set firewall "$CONFIG_SECTION" vpn_type 'IPsec'
uci_set firewall "$CONFIG_SECTION" proto 'esp'
uci_add firewall rule
uci_set firewall "$CONFIG_SECTION" dest_port '4500'
uci_set firewall "$CONFIG_SECTION" src 'wan'
uci_set firewall "$CONFIG_SECTION" name 'Allow-IPsec-NAT-T'
uci_set firewall "$CONFIG_SECTION" target 'ACCEPT'
uci_set firewall "$CONFIG_SECTION" vpn_type 'IPsec'
uci_set firewall "$CONFIG_SECTION" proto 'udp'
uci_add firewall rule
uci_set firewall "$CONFIG_SECTION" dest_port '500'
uci_set firewall "$CONFIG_SECTION" src 'wan'
uci_set firewall "$CONFIG_SECTION" name 'Allow-IPsec-IKE'
uci_set firewall "$CONFIG_SECTION" target 'ACCEPT'
uci_set firewall "$CONFIG_SECTION" vpn_type 'IPsec'
uci_set firewall "$CONFIG_SECTION" proto 'udp'
uci_add firewall rule
uci_set firewall "$CONFIG_SECTION" src 'wan'
uci_set firewall "$CONFIG_SECTION" name 'Allow-IPsec-Forward'
uci_set firewall "$CONFIG_SECTION" extra '-m policy --dir in --pol ipsec'
uci_set firewall "$CONFIG_SECTION" target 'ACCEPT'
uci_set firewall "$CONFIG_SECTION" vpn_type 'IPsec'
uci_set firewall "$CONFIG_SECTION" dest '*'
uci_set firewall "$CONFIG_SECTION" proto 'all'
uci_add firewall redirect
uci_set firewall "$CONFIG_SECTION" proto any
uci_set firewall "$CONFIG_SECTION" name Exclude-IPsec-from-NAT
uci_set firewall "$CONFIG_SECTION" extra '-m policy --dir out --pol ipsec'
uci_set firewall "$CONFIG_SECTION" vpn_type IPsec
uci_set firewall "$CONFIG_SECTION" target ACCEPT
uci_set firewall "$CONFIG_SECTION" dest wan
uci_set firewall "$CONFIG_SECTION" enabled 1
uci_commit firewall
}
rm -f /etc/config/strongswan
exit 0

View file

@ -0,0 +1,82 @@
#!/bin/sh
. /lib/functions.sh
#this script move configuration from 1.x firmware
#it should rename some sections and add option disabled to network config
move_config() {
local section="$1"
local file="$2"
config_get_bool enabled "$1" "enabled" "0"
config_get _name "$1" "_name"
config_get _type "$1" "_type"
[ -z "$_type" ] && config_get _type "$1" "type"
[ "$enabled" -eq 1 ] && [ "$_type" = "client" ] && {
uci set network."$1".auto=1
uci_commit "${config}"
}
[ "${_type}_${_name}" = "$section" ] && return
uci_rename "$file" "$section" "${_type:+${_type}_}${_name}"
uci_commit "${config}"
}
move_network() {
local section="$1"
local net_proto net_name net_type net_enabled
config_get net_proto "$section" "proto"
case "$net_proto" in
pptp|\
l2tp)
config_get net_name "$1" "_name"
config_get_bool net_enabled "$1" "enabled"
[ "client_${net_name}" = "$section" ] && return
[ -n "$net_enabled" ] && {
[ "$net_enabled" = "1" ] && uci_set network "$section" disabled 0 || uci_set network "$section" disabled 1
uci_remove network "$section" enabled
}
uci_rename network "$section" "${net_type:+${net_type}_}${net_name}"
uci_commit network
;;
sstp)
config_get_bool net_enabled "$1" "enabled"
[ -z "$net_enabled" ] && return
[ "$net_enabled" = "1" ] && uci_set network "$section" disabled 0 || uci_set network "$section" disabled 1
uci_remove network "$section" enabled
uci_commit network
;;
*)
return
;;
esac
}
# removes client configurations, because they reside in network and with vuci became unncessary
remove_network() {
local section="$1"
local current_config="$2"
local sectionType
config_get sectionType "$1" "type"
if [ "$sectionType" = "client" ]; then
uci_remove "$current_config" "$section"
uci_commit "$current_config"
fi
}
configs="pptpd xl2tpd"
for config in $configs; do
[ -s /etc/config/${config} ] || continue
config_load "$config"
config_foreach move_config "service" "$config"
config_foreach remove_network "service" "$config"
done
[ -s /etc/config/network ] || exit 0
config_load "network"
config_foreach move_network "interface"
exit 0