From cc2aab18676750b6753fe5ffcd3dcdbc37100843 Mon Sep 17 00:00:00 2001 From: Alexey Dobrovolsky Date: Sun, 6 Jun 2021 02:25:02 +0300 Subject: [PATCH 1/7] busybox: sysntpd: add trigger to reload server sysntpd server becomes unavailable if the index of the bound interface changes. So let's add an interface trigger to reload sysntpd. This patch also adds the ability for the sysntpd script to handle uci interface name from configuration. Fixes: 4da60500ebd2 ("busybox: sysntpd: option to bind server to iface") Signed-off-by: Alexey Dobrovolsky Reviewed-by: Philip Prindeville --- package/utils/busybox/files/sysntpd | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/package/utils/busybox/files/sysntpd b/package/utils/busybox/files/sysntpd index 50290a2134..47e88172ea 100755 --- a/package/utils/busybox/files/sysntpd +++ b/package/utils/busybox/files/sysntpd @@ -56,7 +56,14 @@ start_ntpd_instance() { procd_set_param command "$PROG" -n -N if [ "$enable_server" = "1" ]; then procd_append_param command -l - [ -n "$interface" ] && procd_append_param command -I $interface + [ -n "$interface" ] && { + local ifname + + network_get_device ifname "$interface" || \ + ifname="$interface" + procd_append_param command -I "$ifname" + procd_append_param netdev "$ifname" + } fi [ -x "$HOTPLUG_SCRIPT" ] && procd_append_param command -S "$HOTPLUG_SCRIPT" for peer in $server; do @@ -74,11 +81,12 @@ start_ntpd_instance() { } start_service() { + . /lib/functions/network.sh validate_ntp_section ntp start_ntpd_instance } service_triggers() { - local script name use_dhcp + local script name use_dhcp enable_server interface script=$(readlink -f "$initscript") name=$(basename ${script:-$initscript}) @@ -101,5 +109,17 @@ service_triggers() { fi } + config_get_bool enable_server ntp enable_server 0 + config_get interface ntp interface + + [ $enable_server -eq 1 ] && [ -n "$interface" ] && { + local ifname + + network_get_device ifname "$interface" || \ + ifname="$interface" + procd_add_interface_trigger "interface.*" "$ifname" \ + /etc/init.d/"$name" reload + } + procd_add_validation validate_ntp_section } From 627cebdb0f5324ab9b27f3294cc098be44783ae9 Mon Sep 17 00:00:00 2001 From: Rui Salvaterra Date: Thu, 24 Jun 2021 20:05:22 +0100 Subject: [PATCH 2/7] zram-swap: set the zram swap priority to 100 by default New swap devices are added in decreasing priority order, starting at -1. Make sure the zram swap device has the highest priority, by default. Signed-off-by: Rui Salvaterra --- package/system/zram-swap/files/zram.init | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/package/system/zram-swap/files/zram.init b/package/system/zram-swap/files/zram.init index 1a5521f965..35fbafd066 100755 --- a/package/system/zram-swap/files/zram.init +++ b/package/system/zram-swap/files/zram.init @@ -143,7 +143,10 @@ start() local zram_size="$( zram_getsize )" local zram_priority="$( uci -q get system.@system[0].zram_priority )" - zram_priority=${zram_priority:+-p $zram_priority} + + if [ -z "$zram_priority" ]; then + zram_priority="100" + fi logger -s -t zram_start -p daemon.debug "activating '$zram_dev' for swapping ($zram_size MegaBytes)" @@ -151,7 +154,7 @@ start() zram_comp_algo "$zram_dev" echo $(( $zram_size * 1024 * 1024 )) >"/sys/block/$( basename "$zram_dev" )/disksize" busybox mkswap "$zram_dev" - busybox swapon -d $zram_priority "$zram_dev" + busybox swapon -d -p $zram_priority "$zram_dev" } stop() From fb08594769b90a205691b474bd4183a8562e7794 Mon Sep 17 00:00:00 2001 From: Rui Salvaterra Date: Thu, 24 Jun 2021 20:05:23 +0100 Subject: [PATCH 3/7] zram-swap: clean up the log messages Remove redundant tags and name things more consistently. Signed-off-by: Rui Salvaterra [removed superflous dash] Signed-off-by: Paul Spooren --- package/system/zram-swap/files/zram.init | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/package/system/zram-swap/files/zram.init b/package/system/zram-swap/files/zram.init index 35fbafd066..1a9cefeff5 100755 --- a/package/system/zram-swap/files/zram.init +++ b/package/system/zram-swap/files/zram.init @@ -2,8 +2,8 @@ START=15 -extra_command "compact" "Trigger compaction for all Z-RAM swap dev's" -extra_command "status" "Print out information & statistics about Z-RAM swap devices" +extra_command "compact" "Trigger compaction for all zram swap devices" +extra_command "status" "Print out information & statistics about zram swap devices" ram_getsize() { @@ -59,15 +59,16 @@ zram_comp_algo() local dev="$1" local zram_comp_algo="$( uci -q get system.@system[0].zram_comp_algo )" - if [ -z "$zram_comp_algo" ] || [ ! -e /sys/block/$( basename $dev )/comp_algorithm ]; then - return 0 + if [ -z "$zram_comp_algo" ]; then + # default to lzo, which is always available + zram_comp_algo="lzo" fi if [ $(grep -c "$zram_comp_algo" /sys/block/$( basename $dev )/comp_algorithm) -ne 0 ]; then - logger -s -t zram_comp_algo -p daemon.debug "Set compression algorithm '$zram_comp_algo' for zram '$dev'" + logger -s -t zram_comp_algo -p daemon.debug "set compression algorithm '$zram_comp_algo' for zram '$dev'" echo $zram_comp_algo > "/sys/block/$( basename $dev )/comp_algorithm" else - logger -s -t zram_comp_algo -p daemon.debug "Compression algorithm '$zram_comp_algo' is not supported for '$dev'" + logger -s -t zram_comp_algo -p daemon.debug "compression algorithm '$zram_comp_algo' is not supported for '$dev'" fi } @@ -78,7 +79,7 @@ zram_stats() printf "\nGathering stats info for zram device \"$( basename "$1" )\"\n\n" - printf "Z-RAM\n-----\n" + printf "ZRAM\n----\n" printf "%-25s - %s\n" "Block device" $zdev awk '{ printf "%-25s - %d MiB\n", "Device size", $1/1024/1024 }' <$zdev/disksize printf "%-25s - %s\n" "Compression algo" "$(cat $zdev/comp_algorithm)" @@ -130,7 +131,7 @@ start() } if [ $( grep -cs zram /proc/swaps ) -ne 0 ]; then - logger -s -t zram_start -p daemon.notice "[OK] zram swap is already mounted" + logger -s -t zram_start -p daemon.notice "zram swap is already mounted" return 1 fi @@ -148,7 +149,7 @@ start() zram_priority="100" fi - logger -s -t zram_start -p daemon.debug "activating '$zram_dev' for swapping ($zram_size MegaBytes)" + logger -s -t zram_start -p daemon.debug "activating '$zram_dev' for swapping ($zram_size MiB)" zram_reset "$zram_dev" "enforcing defaults" zram_comp_algo "$zram_dev" From aeff8e17c86330a9888f939d50eb607c31dc0cb6 Mon Sep 17 00:00:00 2001 From: coolsnowwolf Date: Tue, 22 Jun 2021 12:57:40 +0800 Subject: [PATCH 4/7] autocore-arm: remove the dependency on lm-sensors --- package/emortal/autocore/Makefile | 3 +-- package/emortal/autocore/files/arm/sbin/tempinfo | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/package/emortal/autocore/Makefile b/package/emortal/autocore/Makefile index d6f0a0c15f..e5d3f5b3b0 100644 --- a/package/emortal/autocore/Makefile +++ b/package/emortal/autocore/Makefile @@ -21,8 +21,7 @@ define Package/autocore-arm MAINTAINER:=CN_SZTL DEPENDS:=@(TARGET_bcm27xx||TARGET_bcm53xx||TARGET_ipq40xx||TARGET_ipq806x||TARGET_mvebu||TARGET_sunxi) \ +TARGET_bcm27xx:bcm27xx-userland \ - +TARGET_bcm53xx:nvram \ - +(TARGET_ipq40xx||TARGET_ipq806x):lm-sensors + +TARGET_bcm53xx:nvram VARIANT:=arm endef diff --git a/package/emortal/autocore/files/arm/sbin/tempinfo b/package/emortal/autocore/files/arm/sbin/tempinfo index 812d1750f4..278f23f93b 100755 --- a/package/emortal/autocore/files/arm/sbin/tempinfo +++ b/package/emortal/autocore/files/arm/sbin/tempinfo @@ -5,11 +5,11 @@ if [ -e "${mt76_path}" ]; then mt76_temp=" $(cat "${mt76_path}" | awk -F ': ' '{print $2}')°C" fi -sys_temp="$(sensors | grep -Eo '\+[0-9]+.+C' | grep -Ev 'high' | sed ':a;N;$!ba;s/\n/ /g;s/+//g')" +wifi_temp="$(awk '{printf("%.1f°C ", $0 / 1000)}' /sys/class/ieee80211/phy*/device/hwmon/hwmon*/temp1_input)" if grep -q "ipq40xx" "/etc/openwrt_release"; then - echo -n "WiFi:${mt76_temp} ${sys_temp}" + echo -n "WiFi:${mt76_temp} ${wifi_temp}" else - cpu_temp="$(awk "BEGIN{printf (\"%.1f\n\",$(cat /sys/class/thermal/thermal_zone0/temp)/1000) }")°C" - echo -n "CPU: ${cpu_temp}, WiFi: ${sys_temp}" + cpu_temp="$(awk '{printf("%.1f°C", $0 / 1000)}' /sys/class/thermal/thermal_zone0/temp)" + echo -n "CPU: ${cpu_temp}, WiFi: ${wifi_temp}" fi From 268a5e1191562dff8fbb7c80d08e56e31bfbf2cf Mon Sep 17 00:00:00 2001 From: AmadeusGhost <42570690+AmadeusGhost@users.noreply.github.com> Date: Mon, 28 Jun 2021 23:01:54 +0800 Subject: [PATCH 5/7] autocore-arm: no longer limit the specific target MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These code are good enough to do this. Now we don’t need to make this line longer and longer. --- package/emortal/autocore/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package/emortal/autocore/Makefile b/package/emortal/autocore/Makefile index e5d3f5b3b0..75f126a6e0 100644 --- a/package/emortal/autocore/Makefile +++ b/package/emortal/autocore/Makefile @@ -11,15 +11,15 @@ include $(TOPDIR)/rules.mk PKG_NAME:=autocore -PKG_VERSION:=1 -PKG_RELEASE:=40 +PKG_VERSION:=2 +PKG_RELEASE:=$(COMMITCOUNT) include $(INCLUDE_DIR)/package.mk define Package/autocore-arm TITLE:=Arm auto core loadbalance script. MAINTAINER:=CN_SZTL - DEPENDS:=@(TARGET_bcm27xx||TARGET_bcm53xx||TARGET_ipq40xx||TARGET_ipq806x||TARGET_mvebu||TARGET_sunxi) \ + DEPENDS:=@(arm||aarch64) \ +TARGET_bcm27xx:bcm27xx-userland \ +TARGET_bcm53xx:nvram VARIANT:=arm From d2364ce1fa5888f9c9a1bc5c2f18f86eae6f0361 Mon Sep 17 00:00:00 2001 From: Tianling Shen Date: Tue, 29 Jun 2021 22:06:09 +0800 Subject: [PATCH 6/7] autocore: strip white space Signed-off-by: Tianling Shen --- package/emortal/autocore/files/arm/sbin/tempinfo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/emortal/autocore/files/arm/sbin/tempinfo b/package/emortal/autocore/files/arm/sbin/tempinfo index 278f23f93b..29e6e62944 100755 --- a/package/emortal/autocore/files/arm/sbin/tempinfo +++ b/package/emortal/autocore/files/arm/sbin/tempinfo @@ -5,7 +5,7 @@ if [ -e "${mt76_path}" ]; then mt76_temp=" $(cat "${mt76_path}" | awk -F ': ' '{print $2}')°C" fi -wifi_temp="$(awk '{printf("%.1f°C ", $0 / 1000)}' /sys/class/ieee80211/phy*/device/hwmon/hwmon*/temp1_input)" +wifi_temp="$(awk '{printf("%.1f°C ", $0 / 1000)}' /sys/class/ieee80211/phy*/device/hwmon/hwmon*/temp1_input | awk '$1=$1')" if grep -q "ipq40xx" "/etc/openwrt_release"; then echo -n "WiFi:${mt76_temp} ${wifi_temp}" From f76307035c74562572cbe7c43774b747867c68a1 Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Sun, 27 Jun 2021 22:02:46 +0000 Subject: [PATCH 7/7] dnsmasq: distinct Ubus names for multiple instances Currently, when using multiple dnsmasq instances they are all assigned to the same Ubus instance name. This does not work, as only a single instance can register with Ubus at a time. In the log, this leads to `Cannot add object to UBus: Invalid argument` error messages. Furthermore, upstream 3c93e8eb41952a9c91699386132d6fe83050e9be changes behaviour so that instead of the log, dnsmasq exits at start instead. With this patch, all dnsmasq instances are assigned unique names so that they can register with Ubus concurrently. One of the enabled instances is always assigned the previous default name "dnsmasq" to avoid breaking backwards compatibility with other software relying on that default. Previously, a random instance got assigned that name (while the others produced error logs). Now, the first unnamed dnsmasq config section is assigned the default name. If there are no unnamed dnsmasq sections the first encountered named dnsmasq config section is assigned instead. A similar issue exists for Dbus and was similarly addressed. Signed-off-by: Etan Kissling [tweaked commit message] dnsmasq was not crashing it is exiting Signed-off-by: Kevin Darbyshire-Bryant --- .../services/dnsmasq/files/dnsmasq.init | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/package/network/services/dnsmasq/files/dnsmasq.init b/package/network/services/dnsmasq/files/dnsmasq.init index 4c0a324657..eea55d724a 100644 --- a/package/network/services/dnsmasq/files/dnsmasq.init +++ b/package/network/services/dnsmasq/files/dnsmasq.init @@ -161,7 +161,7 @@ append_server() { } append_rev_server() { - xappend "--rev-server=$1" + xappend "--rev-server=$1" } append_address() { @@ -878,8 +878,16 @@ dnsmasq_start() append_bool "$cfg" noresolv "--no-resolv" append_bool "$cfg" localise_queries "--localise-queries" append_bool "$cfg" readethers "--read-ethers" - append_bool "$cfg" dbus "--enable-dbus" - append_bool "$cfg" ubus "--enable-ubus" 1 + + local instance_name="dnsmasq.$cfg" + if [ "$cfg" = "$DEFAULT_INSTANCE" ]; then + instance_name="dnsmasq" + fi + config_get_bool dbus "$cfg" "dbus" 0 + [ $dbus -gt 0 ] && xappend "--enable-dbus=uk.org.thekelleys.$instance_name" + config_get_bool ubus "$cfg" "ubus" 1 + [ $ubus -gt 0 ] && xappend "--enable-ubus=$instance_name" + append_bool "$cfg" expandhosts "--expand-hosts" config_get tftp_root "$cfg" "tftp_root" [ -n "$tftp_root" ] && mkdir -p "$tftp_root" && append_bool "$cfg" enable_tftp "--enable-tftp" @@ -1177,6 +1185,7 @@ boot() start_service() { local instance="$1" local instance_found=0 + local first_instance="" . /lib/functions/network.sh @@ -1187,10 +1196,27 @@ start_service() { if [ -n "$instance" ] && [ "$instance" = "$name" ]; then instance_found=1 fi + if [ -z "$DEFAULT_INSTANCE" ]; then + local disabled + config_get_bool disabled "$name" disabled 0 + if [ "$disabled" -eq 0 ]; then + # First enabled section will be assigned default instance name. + # Unnamed sections get precedence over named sections. + if expr "$cfg" : 'cfg[0-9a-f]*$' >/dev/null = "9"; then # See uci_fixup_section. + DEFAULT_INSTANCE="$name" # Unnamed config section. + elif [ -z "$first_instance" ]; then + first_instance="$name" + fi + fi + fi fi } + DEFAULT_INSTANCE="" config_load dhcp + if [ -z "$DEFAULT_INSTANCE" ]; then + DEFAULT_INSTANCE="$first_instance" # No unnamed config section was found. + fi if [ -n "$instance" ]; then [ "$instance_found" -gt 0 ] || return