From 9a39424c97152e457f5fbe61e1d16d8377156ed4 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Tue, 10 Sep 2024 19:42:32 +0200 Subject: [PATCH 1/4] Fix reinstall packages after update --- luci-app-sysupgrade/root/etc/init.d/sysupgrade | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/luci-app-sysupgrade/root/etc/init.d/sysupgrade b/luci-app-sysupgrade/root/etc/init.d/sysupgrade index 9ffc3c537..44aac9fa8 100755 --- a/luci-app-sysupgrade/root/etc/init.d/sysupgrade +++ b/luci-app-sysupgrade/root/etc/init.d/sysupgrade @@ -1,5 +1,5 @@ #!/bin/sh /etc/rc.common -# Copyright (C) 2020-2021 Ycarus (Yannick Chabanois) +# Copyright (C) 2020-2024 Ycarus (Yannick Chabanois) # Released under GPL 3. See LICENSE for the full terms. { @@ -11,8 +11,8 @@ start_service() { if [ -f /etc/backup/installed_packages.txt ]; then - if [ "$(opkg -V0 update 2>&1)" = "" ]; then - grep "\toverlay" /etc/backup/installed_packages.txt | cut -f1 | xargs -r opkg -V0 install + opkg -V0 update >/dev/null 2>&1 + if [ -z "$(grep '\toverlay' /etc/backup/installed_packages.txt | cut -f1 | xargs -r opkg -V0 install)" ]; then rm /etc/backup/installed_packages.txt fi fi From 3a7669aef08a6aa8f0bf893d4ea31659cd4532c2 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Tue, 10 Sep 2024 19:43:54 +0200 Subject: [PATCH 2/4] Move sysupgrade init script to openmptcprouter package --- .../root => openmptcprouter/files}/etc/init.d/sysupgrade | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {luci-app-sysupgrade/root => openmptcprouter/files}/etc/init.d/sysupgrade (100%) diff --git a/luci-app-sysupgrade/root/etc/init.d/sysupgrade b/openmptcprouter/files/etc/init.d/sysupgrade similarity index 100% rename from luci-app-sysupgrade/root/etc/init.d/sysupgrade rename to openmptcprouter/files/etc/init.d/sysupgrade From 1e705d2cb529725a79d5ab73a258536100804d55 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Wed, 11 Sep 2024 08:35:15 +0200 Subject: [PATCH 3/4] Check if we have a return from mmcli -L before using it in Wizard --- .../luasrc/view/openmptcprouter/wizard.htm | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm b/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm index 7fc7ad7b8..0d715c027 100644 --- a/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm +++ b/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm @@ -46,12 +46,14 @@ alltty = {} iftty = luci.sys.exec("timeout 1 /usr/bin/mmcli -L") - for listtty in iftty:gmatch("([^\r\n]*)[\r\n]") do - modemid = luci.util.trim(luci.sys.exec("echo '" .. listtty .. "' | awk -F' ' '{print $1}' | awk -F/ '{print $6}'")) - if modemid ~= '' then - modeminfo = luci.sys.exec("timeout 1 /usr/bin/mmcli -m " .. modemid .. " --output-keyvalue") - tty = luci.util.trim(luci.sys.exec("echo '" .. modeminfo .. "' | grep 'modem.generic.device ' | awk -F': ' '{print $2}'")) - table.insert(alltty, tty) + if iftty ~= nil then + for listtty in iftty:gmatch("([^\r\n]*)[\r\n]") do + modemid = luci.util.trim(luci.sys.exec("echo '" .. listtty .. "' | awk -F' ' '{print $1}' | awk -F/ '{print $6}'")) + if modemid ~= '' then + modeminfo = luci.sys.exec("timeout 1 /usr/bin/mmcli -m " .. modemid .. " --output-keyvalue") + tty = luci.util.trim(luci.sys.exec("echo '" .. modeminfo .. "' | grep 'modem.generic.device ' | awk -F': ' '{print $2}'")) + table.insert(alltty, tty) + end end end From b1a32ce3b3d0c15a6493825f3fcb631c32bda93f Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Wed, 11 Sep 2024 13:39:34 +0200 Subject: [PATCH 4/4] Faster detection of link down in OMR-Tracker --- omr-tracker/files/bin/omr-tracker | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/omr-tracker/files/bin/omr-tracker b/omr-tracker/files/bin/omr-tracker index 94ecf24ad..330f8933b 100755 --- a/omr-tracker/files/bin/omr-tracker +++ b/omr-tracker/files/bin/omr-tracker @@ -287,15 +287,15 @@ while true; do } if [ -n "$OMR_TRACKER_DEVICE" ] && [ -d "/sys/class/net/$OMR_TRACKER_DEVICE" ]; then - #if [ -n "$(ip link show $OMR_TRACKER_DEVICE | grep 'state UP')" ] || [ -n "$(ip link show $OMR_TRACKER_DEVICE | grep 'state UNKNOWN')" ]; then - if [ "$(ifstatus $OMR_TRACKER_INTERFACE | jsonfilter -q -e '@.up')" == "true" ] || [ "$OMR_TRACKER_INTERFACE" = "omrvpn" ]; then + OMR_TRACKER_DEVICE_STATE=$(ip -j link show dev "$OMR_TRACKER_DEVICE" | jsonfilter -q -e '@[*].operstate' | tr -d '\n') + if ([ "$(ifstatus $OMR_TRACKER_INTERFACE | jsonfilter -q -e '@.up')" == "true" ] && [ "$OMR_TRACKER_DEVICE_STATE" != "DOWN" ]) || [ "$OMR_TRACKER_INTERFACE" = "omrvpn" ]; then # retrieve iface ip and gateway if { [ "$OMR_TRACKER_FAMILY" = "ipv4" ] || [ "$OMR_TRACKER_FAMILY" = "ipv4ipv6" ]; } && [ "$OMR_TRACKER_INTERFACE_PROTO" != "dhcpv6" ]; then OMR_TRACKER_DEVICE_IP=$(ip -4 -br addr ls dev "$OMR_TRACKER_DEVICE" | awk -F'[ /]+' '{print $3}') if [ -z "$OMR_TRACKER_DEVICE_IP" ]; then OMR_TRACKER_DEVICE_IP=$(ip -4 addr show dev "$OMR_TRACKER_DEVICE" | grep -m 1 inet | awk '{print $2}' | cut -d'/' -s -f1) fi - #OMR_TRACKER_DEVICE_IP=$(ubus call network.interface.$OMR_TRACKER_INTERFACE status | jsonfilter -e '@["ipv4-address"][0].address' | tr -d "\n") + #OMR_TRACKER_DEVICE_IP=$(ubus call network.interface.$OMR_TRACKER_INTERFACE status | jsonfilter -q -e '@["ipv4-address"][0].address' | tr -d "\n") #if [ -z "$OMR_TRACKER_DEVICE_GATEWAY" ]; then # OMR_TRACKER_DEVICE_GATEWAY=$(ip -4 r list dev "$OMR_TRACKER_DEVICE" | grep -v default | awk '/proto static/ {print $1}' | tr -d "\n") #fi