Merge Mainline

This commit is contained in:
AmadeusGhost 2021-07-01 23:28:03 +08:00
commit 9286772e83
5 changed files with 74 additions and 25 deletions

View File

@ -11,18 +11,17 @@
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_rockchip||TARGET_sunxi) \
DEPENDS:=@(arm||aarch64) \
+TARGET_bcm27xx:bcm27xx-userland \
+TARGET_bcm53xx:nvram \
+(TARGET_ipq40xx||TARGET_ipq806x):lm-sensors
+TARGET_bcm53xx:nvram
VARIANT:=arm
endef

View File

@ -1,10 +1,10 @@
#!/bin/sh
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 | awk '$1=$1')"
if grep -q "ipq40xx" "/etc/openwrt_release"; then
echo -n "WiFi: ${sys_temp}"
echo -n "WiFi: ${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

View File

@ -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

View File

@ -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
@ -143,15 +144,18 @@ start()
local zram_size="$( zram_getsize )"
local zram_priority="$( uci -q get system.@system[0].zram_priority )"
zram_priority=${zram_priority:+-p $zram_priority}
logger -s -t zram_start -p daemon.debug "activating '$zram_dev' for swapping ($zram_size MegaBytes)"
if [ -z "$zram_priority" ]; then
zram_priority="100"
fi
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"
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()

View File

@ -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
}