diff --git a/package/emortal/autocore/Makefile b/package/emortal/autocore/Makefile new file mode 100644 index 0000000000..bf13fc73a6 --- /dev/null +++ b/package/emortal/autocore/Makefile @@ -0,0 +1,51 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Copyright (C) 2020 Lean +# Copyright (C) 2021-2023 ImmortalWrt.org + +include $(TOPDIR)/rules.mk + +PKG_NAME:=autocore +PKG_FLAGS:=nonshared +PKG_RELEASE:=42 + +PKG_CONFIG_DEPENDS:= \ + CONFIG_TARGET_bcm27xx \ + CONFIG_TARGET_bcm53xx \ + CONFIG_TARGET_x86 + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/target.mk + +define Package/autocore + TITLE:=auto core loadbalance script. + DEPENDS:=@(aarch64||arm||i386||i686||x86_64) \ + +TARGET_bcm27xx:bcm27xx-utils \ + +TARGET_bcm53xx:nvram \ + +TARGET_x86:ethtool \ + +TARGET_x86:lm-sensors +endef + +define Build/Compile +endef + +define Package/autocore/install + $(INSTALL_DIR) $(1)/etc/uci-defaults + $(INSTALL_BIN) ./files/60-autocore-reload-rpcd $(1)/etc/uci-defaults/ + +ifneq ($(filter i386 i686 x86_64, $(ARCH)),) + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/autocore $(1)/etc/init.d/ +endif + + $(INSTALL_DIR) $(1)/sbin + $(INSTALL_BIN) ./files/cpuinfo $(1)/sbin/ +ifneq ($(filter ipq% mediatek% qualcommax%, $(TARGETID)),) + $(INSTALL_BIN) ./files/tempinfo $(1)/sbin/ +endif + + $(INSTALL_DIR) $(1)/usr/share/rpcd/acl.d + $(CP) ./files/luci-mod-status-autocore.json $(1)/usr/share/rpcd/acl.d/ +endef + +$(eval $(call BuildPackage,autocore)) diff --git a/package/emortal/autocore/files/60-autocore-reload-rpcd b/package/emortal/autocore/files/60-autocore-reload-rpcd new file mode 100755 index 0000000000..75e8178bb8 --- /dev/null +++ b/package/emortal/autocore/files/60-autocore-reload-rpcd @@ -0,0 +1,5 @@ +#!/bin/sh + +/etc/init.d/rpcd restart + +exit 0 diff --git a/package/emortal/autocore/files/autocore b/package/emortal/autocore/files/autocore new file mode 100755 index 0000000000..a54ac01b40 --- /dev/null +++ b/package/emortal/autocore/files/autocore @@ -0,0 +1,42 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2017 lean + +START=99 + +start() { + rfc=4096 + threads="$(grep -c "processor" "/proc/cpuinfo")" + + sysctl -w net.core.rps_sock_flow_entries="$(( rfc * threads ))" + + for fileRps in /sys/class/net/eth*/queues/rx-*/rps_cpus + do + echo "$threads" > "$fileRps" + done + + for fileRfc in /sys/class/net/eth*/queues/rx-*/rps_flow_cnt + do + echo "$rfc" > "$fileRfc" + done + + uci set network.@globals[0].packet_steering="1" + uci commit network + + for i in $(ip address | awk -F ': ' '/eth[0-9]+/ {print $2}' | grep -v '@' | xargs) + do + ethtool -K "$i" rx-checksum on + ethtool -K "$i" tx-checksum-ip-generic on || { + ethtool -K "$i" tx-checksum-ipv4 on + ethtool -K "$i" tx-checksum-ipv6 on + } + ethtool -K "$i" tx-scatter-gather on + ethtool -K "$i" gso on + ethtool -K "$i" tso on + ethtool -K "$i" ufo on + + if ethtool -i "$i" | grep -q "driver: igc"; then + ethtool -G "$i" rx "$(ethtool -g "$i" | awk '/^RX:/ {print $2; exit}')" + ethtool -G "$i" tx "$(ethtool -g "$i" | awk '/^TX:/ {print $2; exit}')" + fi + done +} >"/dev/null" 2>&1 diff --git a/package/emortal/autocore/files/cpuinfo b/package/emortal/autocore/files/cpuinfo new file mode 100755 index 0000000000..895bb70b43 --- /dev/null +++ b/package/emortal/autocore/files/cpuinfo @@ -0,0 +1,61 @@ +#!/bin/sh + +. /etc/openwrt_release + +CPUINFO_PATH="/proc/cpuinfo" +CPUFREQ_PATH="/sys/devices/system/cpu/cpufreq" +THERMAL_PATH="/sys/class/thermal" + +cpu_arch="$(awk -F ': ' '/model name/ {print $2}' "$CPUINFO_PATH" | head -n1)" +[ -n "${cpu_arch}" ] || cpu_arch="?" + +case "$DISTRIB_TARGET" in +"x86"/*) + cpu_cores="$(grep "core id" "$CPUINFO_PATH" | sort -u | wc -l)C $(grep -c "processor" "$CPUINFO_PATH")T" ;; +*) + cpu_cores="$(grep -c "processor" "$CPUINFO_PATH")" ;; +esac + +case "$DISTRIB_TARGET" in +"bcm27xx"/*) + cpu_freq="$(( $(vcgencmd measure_clock arm | awk -F '=' '{print $2}') / 1000000 ))Mhz" ;; +"bcm53xx"/*) + cpu_freq="$(nvram get clkfreq | awk -F ',' '{print $1}')MHz" ;; +"rockchip"/*) + cpu_freq="$(awk '{printf("%.fMHz ", $0 / 1000)}' "$CPUFREQ_PATH"/policy*/cpuinfo_cur_freq | awk '$1=$1')" ;; +"x86"/*) + cpu_freq="$(awk -F ': ' '/MHz/ {print $2}' "$CPUINFO_PATH" | head -n1)MHz" ;; +*) + [ ! -e "$CPUFREQ_PATH/policy0/cpuinfo_cur_freq" ] || \ + cpu_freq="$(awk '{printf("%.fMHz", $0 / 1000)}' "$CPUFREQ_PATH/policy0/cpuinfo_cur_freq")" + ;; +esac + +case "$DISTRIB_TARGET" in +"bcm27xx"/*) + cpu_temp="$(vcgencmd measure_temp | awk -F '=' '{print $2}' | awk -F "'" '{print $1}')°C" ;; +"ipq40xx"/*|"ipq806x"/*|"mediatek"/*|"qualcommax"/*) ;; +"x86"/*) + if [ -n "$(uci -q get "wechatpush.config.server_host")" ]; then + cpu_temp="$(/usr/share/wechatpush/wechatpush soc)°C" + elif grep -q "GenuineIntel" "/proc/cpuinfo"; then + cpu_temp="$(sensors "coretemp-*" 2>"/dev/null" | grep -E "(Package id |Core )" | grep -Eo "\+[0-9.]*°C" | head -n1 | tr -d "+")" + elif grep -q "AuthenticAMD" "/proc/cpuinfo"; then + cpu_temp="$(sensors "k*temp-*" 2>"/dev/null" | awk '/Tdie/ {print $2}' | head -n1 | tr -d "+")" + fi + ;; +*) + [ ! -e "$THERMAL_PATH/thermal_zone0/temp" ] || \ + cpu_temp="$(awk '{printf("%.1f°C", $0 / 1000)}' "$THERMAL_PATH/thermal_zone0/temp")" + ;; +esac + +if [ -z "$cpu_freq" ] && [ -n "$cpu_temp" ]; then + echo -n "$cpu_arch x $cpu_cores ($cpu_temp)" +elif [ -z "$cpu_temp" ] && [ -n "$cpu_freq" ]; then + echo -n "$cpu_arch x $cpu_cores ($cpu_freq)" +elif [ -n "$cpu_temp" ] && [ -n "$cpu_freq" ]; then + echo -n "$cpu_arch x $cpu_cores ($cpu_freq, ${cpu_temp})" +else + echo -n "$cpu_arch x $cpu_cores" +fi diff --git a/package/emortal/autocore/files/luci-mod-status-autocore.json b/package/emortal/autocore/files/luci-mod-status-autocore.json new file mode 100644 index 0000000000..5e2330a2da --- /dev/null +++ b/package/emortal/autocore/files/luci-mod-status-autocore.json @@ -0,0 +1,10 @@ +{ + "luci-mod-status-autocore": { + "description": "Grant access to autocore", + "read": { + "ubus": { + "luci": [ "getCPUInfo", "getTempInfo" ] + } + } + } +} diff --git a/package/emortal/autocore/files/tempinfo b/package/emortal/autocore/files/tempinfo new file mode 100755 index 0000000000..c9fbd6d34e --- /dev/null +++ b/package/emortal/autocore/files/tempinfo @@ -0,0 +1,40 @@ +#!/bin/sh + +. /etc/openwrt_release + +IEEE_PATH="/sys/class/ieee80211" +THERMAL_PATH="/sys/class/thermal" + +case "$DISTRIB_TARGET" in +ipq40xx/*|ipq806x/*) + wifi_temp="$(awk '{printf("%.1f°C ", $0 / 1000)}' "$IEEE_PATH"/phy*/device/hwmon/hwmon*/temp1_input 2>"/dev/null" | awk '$1=$1')" + ;; +mediatek/mt7622) + wifi_temp="$(awk '{printf("%.1f°C ", $0 / 1000)}' "$IEEE_PATH"/wl*/hwmon*/temp1_input 2>"/dev/null" | awk '$1=$1')" + ;; +*) + wifi_temp="$(awk '{printf("%.1f°C ", $0 / 1000)}' "$IEEE_PATH"/phy*/hwmon*/temp1_input 2>"/dev/null" | awk '$1=$1')" + ;; +esac + +case "$DISTRIB_TARGET" in +ipq40xx/*) + if [ -e "$IEEE_PATH/phy0/hwmon0/temp1_input" ]; then + mt76_temp="$(awk -F ': ' '{print $2}' "$IEEE_PATH/phy0/hwmon0/temp1_input" 2>"/dev/null")°C" + fi + [ -z "$mt76_temp" ] || wifi_temp="${wifi_temp:+$wifi_temp }$mt76_temp" + ;; +*) + cpu_temp="$(awk '{printf("%.1f°C", $0 / 1000)}' "$THERMAL_PATH/thermal_zone0/temp" 2>"/dev/null")" + ;; +esac + +if [ -n "$cpu_temp" ] && [ -z "$wifi_temp" ]; then + echo -n "CPU: $cpu_temp" +elif [ -z "$cpu_temp" ] && [ -n "$wifi_temp" ]; then + echo -n "WiFi: $wifi_temp" +elif [ -n "$cpu_temp" ] && [ -n "$wifi_temp" ]; then + echo -n "CPU: $cpu_temp, WiFi: $wifi_temp" +else + echo -n "No temperature info" +fi diff --git a/package/emortal/automount/Makefile b/package/emortal/automount/Makefile new file mode 100644 index 0000000000..a7c5a20055 --- /dev/null +++ b/package/emortal/automount/Makefile @@ -0,0 +1,63 @@ +# +# Copyright (C) 2010-2011 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=automount +PKG_FLAGS:=nonshared +PKG_RELEASE:=10 + +PKG_CONFIG_DEPENDS:= \ + CONFIG_TARGET_ramips + +include $(INCLUDE_DIR)/package.mk + +define Package/automount + TITLE:=Mount autoconfig hotplug script. + MAINTAINER:=Lean + DEPENDS:= \ + +block-mount \ + +e2fsprogs \ + +kmod-usb-storage \ + +kmod-usb-storage-extras \ + +!TARGET_ramips:kmod-usb-storage-uas \ + +kmod-fs-ext4 \ + +kmod-fs-exfat \ + +kmod-fs-vfat \ + +ntfs3-mount + PKGARCH:=all +endef + +define Package/ntfs3-mount + SECTION:=utils + CATEGORY:=Utilities + SUBMENU:=Filesystem + TITLE:=NTFS mount script for Paragon NTFS3 driver + DEPENDS:=+kmod-fs-ntfs3 + CONFLICTS:=ntfs-3g + VARIANT:=ntfs3-mount + PKGARCH:=all +endef + +define Build/Compile +endef + +define Package/automount/install + $(INSTALL_DIR) $(1)/etc/uci-defaults + $(INSTALL_BIN) ./files/11-anonmount $(1)/etc/uci-defaults/ + + $(INSTALL_DIR) $(1)/etc/hotplug.d/block + $(INSTALL_BIN) ./files/15-automount $(1)/etc/hotplug.d/block/ +endef + +define Package/ntfs3-mount/install + $(INSTALL_DIR) $(1)/sbin + $(INSTALL_BIN) ./files/mount.ntfs $(1)/sbin +endef + +$(eval $(call BuildPackage,automount)) +$(eval $(call BuildPackage,ntfs3-mount)) diff --git a/package/emortal/automount/files/11-anonmount b/package/emortal/automount/files/11-anonmount new file mode 100644 index 0000000000..552e57ce3e --- /dev/null +++ b/package/emortal/automount/files/11-anonmount @@ -0,0 +1,13 @@ +#!/bin/sh + +if ! uci -q get system.@imm_init[0].anon_mount > "/dev/null"; then + uci -q batch <<-EOF + set fstab.@global[0].anon_mount="1" + commit fstab + + set system.@imm_init[0].anon_mount="1" + commit system + EOF +fi + +exit 0 diff --git a/package/emortal/automount/files/15-automount b/package/emortal/automount/files/15-automount new file mode 100755 index 0000000000..57b5ea987b --- /dev/null +++ b/package/emortal/automount/files/15-automount @@ -0,0 +1,27 @@ +#!/bin/sh + +# Copyright (C) 2015 OpenWrt.org + +# 0 yes blockdevice handles this - 1 no it is not there +blkdev=`dirname $DEVPATH` +basename=`basename $blkdev` +device=`basename $DEVPATH` +skip=`block info | grep -vE '(f2fs|kernel|squashfs|ubifs)' | sed 's/\(.*\): .*/\1/' | grep -q $device ; echo $?` +path=$DEVPATH + +if [ $basename != "block" ] && [ -z "${device##sd*}" ] && [ $skip -eq 1 ]; then + mntpnt=$device + case "$ACTION" in + add) + mkdir -p /mnt/$mntpnt + chmod 777 /mnt/$mntpnt + # Try to be gentle on solid state devices + mount -o rw,noatime,discard /dev/$device /mnt/$mntpnt + ;; + remove) + # Once the device is removed, the /dev entry disappear. We need mountpoint + mountpoint=`mount |grep /dev/$device | sed 's/.* on \(.*\) type.*/\1/'` + umount -l $mountpoint + ;; + esac +fi diff --git a/package/emortal/automount/files/mount.ntfs b/package/emortal/automount/files/mount.ntfs new file mode 100644 index 0000000000..68b7a2e68f --- /dev/null +++ b/package/emortal/automount/files/mount.ntfs @@ -0,0 +1,2 @@ +#!/bin/sh +mount -t ntfs3 -o iocharset=utf8 "$@" diff --git a/package/emortal/autosamba/Makefile b/package/emortal/autosamba/Makefile new file mode 100644 index 0000000000..0e228a0c27 --- /dev/null +++ b/package/emortal/autosamba/Makefile @@ -0,0 +1,35 @@ +# +# Copyright (C) 2010-2011 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=autosamba +PKG_VERSION:=1 +PKG_RELEASE:=12 + +include $(INCLUDE_DIR)/package.mk + +define Package/autosamba + TITLE:=Samba autoconfig hotplug script. + MAINTAINER:=Lean + DEPENDS:=+luci-app-samba4 +wsdd2 + PKGARCH:=all +endef + +define Package/autosamba/description + A hotplug script to config Samba share automatically. +endef + +define Build/Compile +endef + +define Package/autosamba/install + $(INSTALL_DIR) $(1)/etc/hotplug.d/block + $(INSTALL_BIN) ./files/20-smb $(1)/etc/hotplug.d/block/ +endef + +$(eval $(call BuildPackage,autosamba)) diff --git a/package/emortal/autosamba/files/20-smb b/package/emortal/autosamba/files/20-smb new file mode 100644 index 0000000000..ae00f8140d --- /dev/null +++ b/package/emortal/autosamba/files/20-smb @@ -0,0 +1,106 @@ +#!/bin/sh + +# +# D-Team Technology Co.,Ltd. ShenZhen +# 作者:Vic +# +# 警告:对着屏幕的哥们,我们允许你使用此脚本,但不允许你抹去作者的信息,请保留这段话。 +# + +. /lib/functions.sh +. /lib/functions/service.sh + +global=0 +config_file="/etc/config/samba4" + +wait_for_init() { + for i in `seq 30` + do + [ -e /tmp/procd.done ] || { + sleep 1; continue; + } + return + done +} + +smb_handle() { + config_get path $1 path + if [ "$path" = "$2" ] ;then + global=1 + fi +} + +chk_en() { + config_get_bool autoshare $1 autoshare 1 + [ $autoshare -eq 0 ] && exit +} + +config_load samba4 +config_foreach chk_en samba4 + +device=`basename $DEVPATH` + +case "$ACTION" in + add) + + case "$device" in + sd*);; + md*);; + hd*);; + mmcblk*);; + *) return;; + esac + + path="/dev/$device" + + wait_for_init + + cat /proc/mounts | grep -v '/boot\|/opt' | while read j + do + str=${j%% *} + if [ "$str" == $path ];then + strr=${j#* } + target=${strr%% *} + global=0 + config_foreach smb_handle sambashare $target + name=${target#*/mnt/} + + if [ $global -eq 0 ] ;then + echo -e "\n\nconfig sambashare" >> $config_file + echo -e "\toption auto '1'" >> $config_file + echo -e "\toption name '$name'" >> $config_file + echo -e "\toption path '$target'" >> $config_file + echo -e "\toption read_only 'no'" >> $config_file + echo -e "\toption guest_ok 'yes'" >> $config_file + echo -e "\toption create_mask '0666'" >> $config_file + echo -e "\toption dir_mask '0777'" >> $config_file + echo -e "\toption device '$device'" >> $config_file + echo -e "\toption inherit_owner 'yes'" >> $config_file + /etc/init.d/samba4 reload + return + fi + fi + done + ;; + + remove) + i=0 + while true + do + dev=`uci get samba4.@sambashare[$i].device` + [ $? -ne 0 ] && break + + [ "$dev" = "$device" ] && { + auto=`uci get samba4.@sambashare[$i].auto` + [ $auto = "1" ] && { + mount_dir=`uci get samba4.@sambashare[$i].name` + uci delete samba4.@sambashare[$i] + uci commit + /etc/init.d/samba4 reload + return + } + } + let i+=1 + done + ;; +esac diff --git a/package/emortal/cpufreq/Makefile b/package/emortal/cpufreq/Makefile new file mode 100644 index 0000000000..c71f1f36f2 --- /dev/null +++ b/package/emortal/cpufreq/Makefile @@ -0,0 +1,30 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Copyright (C) 2024 ImmortalWrt.org + +include $(TOPDIR)/rules.mk + +PKG_NAME:=cpufreq +PKG_RELEASE:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/cpufreq + TITLE:=CPU Frequency Scaling adjustment tool + DEPENDS:=@(arm||aarch64) + PKGARCH:=all +endef + +define Build/Compile +endef + +define Package/cpufreq/install + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_CONF) $(CURDIR)/files/cpufreq.config $(1)/etc/config/cpufreq + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) $(CURDIR)/files/cpufreq.init $(1)/etc/init.d/cpufreq + $(INSTALL_DIR) $(1)/etc/uci-defaults + $(INSTALL_BIN) $(CURDIR)/files/cpufreq.uci $(1)/etc/uci-defaults/10-cpufreq +endef + +$(eval $(call BuildPackage,cpufreq)) diff --git a/package/emortal/cpufreq/files/cpufreq.config b/package/emortal/cpufreq/files/cpufreq.config new file mode 100644 index 0000000000..9004f1bd87 --- /dev/null +++ b/package/emortal/cpufreq/files/cpufreq.config @@ -0,0 +1,5 @@ + +config settings 'cpufreq' + +config settings 'global' + diff --git a/package/emortal/cpufreq/files/cpufreq.init b/package/emortal/cpufreq/files/cpufreq.init new file mode 100755 index 0000000000..fc5dc47776 --- /dev/null +++ b/package/emortal/cpufreq/files/cpufreq.init @@ -0,0 +1,58 @@ +#!/bin/sh /etc/rc.common + +START=15 +USE_PROCD=1 + +NAME="cpufreq" +CPUFREQ_PATH="/sys/devices/system/cpu/cpufreq" + +extra_command "get_policies" "Get CPU scaling governors and frequencies" + +get_policies() { + json_init + for policy in $(ls -d "$CPUFREQ_PATH"/policy[0-9]* 2>"/dev/null"); do + [ -s "$policy/scaling_available_frequencies" ] || continue + json_add_object "$(basename "$policy")" + json_add_string "index" "$(basename "$policy" | grep -Eo "[0-9]*$")" + json_add_string "cpus" "$(cat "$policy/affected_cpus")" + json_add_array "freqs" + for freq in $(cat "$policy/scaling_available_frequencies"); do + json_add_string "" "$freq" + done + json_close_array + json_add_array "governors" + for governor in $(cat "$policy/scaling_available_governors"); do + json_add_string "" "$governor" + done + json_close_array + json_close_object + done + json_dump +} + +write_cpufreq_config() { + local value + config_get value "$NAME" "$1" + [ -z "$value" ] || echo -n "$value" > "$2" +} + +start_service() { + config_load "$NAME" + + for i in $(ls -d "$CPUFREQ_PATH"/policy[0-9]* 2>"/dev/null" | grep -Eo "[0-9]*$") + do + [ -z "$(config_get "$NAME" "governor$i")" ] && return + + write_cpufreq_config "governor$i" "$CPUFREQ_PATH/policy$i/scaling_governor" + write_cpufreq_config "minfreq$i" "$CPUFREQ_PATH/policy$i/scaling_min_freq" + write_cpufreq_config "maxfreq$i" "$CPUFREQ_PATH/policy$i/scaling_max_freq" + if [ "$(config_get "$NAME" "governor$i")" = "ondemand" ]; then + write_cpufreq_config "sdfactor$i" "$CPUFREQ_PATH/ondemand/sampling_down_factor" + write_cpufreq_config "upthreshold$i" "$CPUFREQ_PATH/ondemand/up_threshold" + fi + done +} + +service_triggers() { + procd_add_reload_trigger "$NAME" +} diff --git a/package/emortal/cpufreq/files/cpufreq.uci b/package/emortal/cpufreq/files/cpufreq.uci new file mode 100644 index 0000000000..ee5bb6cbfd --- /dev/null +++ b/package/emortal/cpufreq/files/cpufreq.uci @@ -0,0 +1,72 @@ +#!/bin/sh + +uci_write_config() { + uci -q set "cpufreq.cpufreq.governor$1"="$2" + uci -q set "cpufreq.cpufreq.minfreq$1"="$3" + uci -q set "cpufreq.cpufreq.maxfreq$1"="$4" + [ -n "$5" ] && uci -q set "cpufreq.cpufreq.sdfactor$1"="$5" + [ -n "$6" ] && uci -q set "cpufreq.cpufreq.upthreshold$1"="$6" + uci -q commit cpufreq +} + +[ "$(uci -q get cpufreq.global.set)" -eq "1" ] && exit 0 + +CPU_FREQS="$(cat '/sys/devices/system/cpu/cpufreq/policy0/scaling_available_frequencies')" +CPU_MIN_FREQ="$(cat '/sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq')" +CPU_MAX_FREQ="$(cat '/sys/devices/system/cpu/cpufreq/policy0/scaling_max_freq')" +CPU_POLICYS="$(find '/sys/devices/system/cpu/cpufreq/policy'* -maxdepth 0 | grep -Eo '[0-9]+')" + +source "/etc/openwrt_release" +case "$DISTRIB_TARGET" in + "bcm27xx/bcm2710"|\ + "bcm27xx/bcm2711") + uci_write_config 0 ondemand 600000 "$CPU_MAX_FREQ" 10 50 + ;; + "ipq40xx/generic") + uci_write_config 0 performance 200000 "$CPU_MAX_FREQ" + ;; + "ipq806x/generic") + uci_write_config 0 performance 600000 "$CPU_MAX_FREQ" + # IPQ8064/5 + echo "$CPU_POLICYS" | grep -q "1" && uci_write_config 1 performance 600000 1200000 + ;; + "mediatek/mt7622") + uci_write_config 0 ondemand 600000 1350000 10 50 + ;; + "qualcommax/ipq60xx"|\ + "qualcommax/ipq807x") + uci_write_config 0 schedutil "$CPU_MIN_FREQ" "$CPU_MAX_FREQ" + ;; + "rockchip/armv8") + if echo "$CPU_POLICYS" | grep -q "6"; then + # RK3588/J/S + uci_write_config 0 schedutil "$CPU_MIN_FREQ" "$CPU_MAX_FREQ" + uci_write_config 4 schedutil "$CPU_MIN_FREQ" "$CPU_MAX_FREQ" + uci_write_config 6 schedutil "$CPU_MIN_FREQ" "$CPU_MAX_FREQ" + elif echo "$CPU_POLICYS" | grep -q "4"; then + # RK3399 + uci_write_config 0 schedutil 600000 1608000 + uci_write_config 4 schedutil 600000 2016000 + else + if ! echo "$CPU_FREQS" | grep -q "1992000"; then + # RK3328 + CPU_MAX_FREQ="1512000" + fi + uci_write_config 0 schedutil 816000 "$CPU_MAX_FREQ" + fi + ;; + "sunxi/cortexa53") + if echo "$CPU_FREQS" | grep -q "1800000"; then + # H6 + uci_write_config 0 schedutil "888000" "$CPU_MAX_FREQ" + elif echo "$CPU_FREQS" | grep -q "1512000"; then + # H616/8 + uci_write_config 0 schedutil "936000" "$CPU_MAX_FREQ" + else + # A64/H5 + uci_write_config 0 schedutil "$CPU_MIN_FREQ" "$CPU_MAX_FREQ" + fi + ;; +esac + +exit 0 diff --git a/package/emortal/default-settings/Makefile b/package/emortal/default-settings/Makefile new file mode 100644 index 0000000000..65a6f52a06 --- /dev/null +++ b/package/emortal/default-settings/Makefile @@ -0,0 +1,43 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Copyright (C) 2021 Lean +# Copyright (C) 2021-2024 ImmortalWrt.org + +include $(TOPDIR)/rules.mk + +PKG_NAME:=default-settings +PKG_RELEASE:=29 + +PKG_LICENSE:=GPL-2.0-only + +include $(INCLUDE_DIR)/package.mk + +define Package/default-settings + SECTION:=luci + CATEGORY:=LuCI + TITLE:=LuCI support for Default Settings + DEPENDS:=+luci + PKGARCH:=all +endef + +define Package/default-settings-chn + $(Package/default-settings) + TITLE+= (Optimize for CHN users) + DEPENDS:=+default-settings +@LUCI_LANG_zh_Hans +luci-i18n-base-zh-cn +endef + +define Build/Compile +endef + +define Package/default-settings/install + $(INSTALL_DIR) $(1)/etc/uci-defaults + $(INSTALL_BIN) ./files/99-default-settings $(1)/etc/uci-defaults/ +endef + +define Package/default-settings-chn/install + $(INSTALL_DIR) $(1)/etc/uci-defaults + $(INSTALL_BIN) ./files/99-default-settings-chinese $(1)/etc/uci-defaults/ +endef + +$(eval $(call BuildPackage,default-settings)) +$(eval $(call BuildPackage,default-settings-chn)) diff --git a/package/emortal/default-settings/files/99-default-settings b/package/emortal/default-settings/files/99-default-settings new file mode 100644 index 0000000000..db753461cc --- /dev/null +++ b/package/emortal/default-settings/files/99-default-settings @@ -0,0 +1,20 @@ +#!/bin/sh + +uci -q get system.@imm_init[0] > "/dev/null" || uci -q add system imm_init > "/dev/null" + +if ! uci -q get system.@imm_init[0].lang > "/dev/null"; then + uci -q batch <<-EOF + set luci.main.lang="auto" + commit luci + + set system.@imm_init[0].lang="1" + commit system + EOF +fi + +sed -i "/log-facility/d" "/etc/dnsmasq.conf" +echo "log-facility=/dev/null" >> "/etc/dnsmasq.conf" + +ln -sf "/sbin/ip" "/usr/bin/ip" + +exit 0 diff --git a/package/emortal/default-settings/files/99-default-settings-chinese b/package/emortal/default-settings/files/99-default-settings-chinese new file mode 100755 index 0000000000..d640c6bf02 --- /dev/null +++ b/package/emortal/default-settings/files/99-default-settings-chinese @@ -0,0 +1,32 @@ +#!/bin/sh + +uci -q get system.@imm_init[0] > "/dev/null" || uci -q add system imm_init > "/dev/null" + +if ! uci -q get system.@imm_init[0].system_chn > "/dev/null"; then + uci -q batch <<-EOF + set system.@system[0].timezone="CST-8" + set system.@system[0].zonename="Asia/Shanghai" + + delete system.ntp.server + add_list system.ntp.server="ntp.tencent.com" + add_list system.ntp.server="ntp1.aliyun.com" + add_list system.ntp.server="ntp.ntsc.ac.cn" + add_list system.ntp.server="cn.ntp.org.cn" + + set system.@imm_init[0].system_chn="1" + commit system + EOF +fi + +opkg_mirror="$(uci -q get system.@imm_init[0].opkg_mirror)" +if [ -z "$opkg_mirror" ]; then + opkg_mirror="https://mirrors.vsean.net/openwrt" + uci -q batch <<-EOF + set system.@imm_init[0].opkg_mirror="$opkg_mirror" + commit system + EOF +fi + +sed -i.bak "s,https://downloads.immortalwrt.org,$opkg_mirror,g" "/etc/opkg/distfeeds.conf" + +exit 0