1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00
openmptcprouter-feeds/luci-app-cpufreq/root/etc/init.d/cpufreq
suyuan168 1020d095bc fix
2022-06-09 11:23:58 +08:00

30 lines
1.1 KiB
Bash
Executable file

#!/bin/sh /etc/rc.common
START=50
NAME=cpufreq
uci_get_by_type() {
local ret=$(uci get $NAME.@$1[0].$2 2>/dev/null)
echo ${ret:=$3}
}
start()
{
local min=$(cat /sys/devices/system/cpu/cpufreq/policy0/scaling_available_frequencies | awk -F ' ' '{print $1 }')
local max=$(cat /sys/devices/system/cpu/cpufreq/policy0/scaling_available_frequencies | awk -F ' ' '{print $NF }')
config_load cpufreq
local governor=$(uci_get_by_type settings governor schedutil)
local minifreq=$(uci_get_by_type settings minifreq $min)
local maxfreq=$(uci_get_by_type settings maxfreq $max)
local upthreshold=$(uci_get_by_type settings upthreshold 50)
local factor=$(uci_get_by_type settings factor 10)
echo $governor > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
echo $minifreq > /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq
echo $maxfreq > /sys/devices/system/cpu/cpufreq/policy0/scaling_max_freq
if [ "$governor" == "ondemand" ]; then
echo $upthreshold > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
echo $factor > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor
fi
}