cpufreqscaling: update

Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
AuxXxilium 2024-11-20 13:10:39 +01:00
parent 0c9b4f1d9b
commit 6271194522
2 changed files with 18 additions and 15 deletions

View File

@ -12,17 +12,17 @@ set -euo pipefail
# Load the correct cpufreq module # Load the correct cpufreq module
cerror=0 cerror=0
governor=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor) governor=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)
if [ "${1}" == "ondemand" ] || [ "${1}" == "conservative" ]; then if [ "${1}" = "ondemand" ] || [ "${1}" = "conservative" ]; then
insmod /usr/lib/modules/cpufreq_${1}.ko || cerror=1 insmod "/usr/lib/modules/cpufreq_${1}.ko" || cerror=1
fi fi
# Set correct cpufreq governor to allow frequency scaling # Set correct cpufreq governor to allow frequency scaling
if [ "${governor}" != "${1}" ]; then if [ "${governor}" != "${1}" ]; then
echo ${1} | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor echo "${1}" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
fi fi
sleep 10 sleep 10
# Check if the governor is set correctly # Check if the governor is set correctly
verifygovernor=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor) verifygovernor=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)
if [ "${verifygovernor}" == "${1}" ]; then if [ "${verifygovernor}" = "${1}" ]; then
echo "CPUFreqScaling: Governor set to ${1}" echo "CPUFreqScaling: Governor set to ${1}"
else else
echo "CPUFreqScaling: Failed to set governor to ${1}" echo "CPUFreqScaling: Failed to set governor to ${1}"

View File

@ -13,7 +13,9 @@ if [ "${1}" = "late" ]; then
cp -pf "/usr/sbin/scaling.sh" "/tmpRoot/usr/sbin/scaling.sh" cp -pf "/usr/sbin/scaling.sh" "/tmpRoot/usr/sbin/scaling.sh"
[ ! -f "/tmpRoot/usr/bin/echo" ] && cp -pf /usr/bin/echo /tmpRoot/usr/bin/echo || true [ ! -f "/tmpRoot/usr/bin/echo" ] && cp -pf /usr/bin/echo /tmpRoot/usr/bin/echo || true
cp -pf "/usr/lib/modules/acpi_cpufreq.ko" "/tmpRoot/usr/lib/modules/acpi_cpufreq.ko" if [ "${2}" = "schedutil" ] || [ "${2}" = "ondemand" ] || [ "${2}" = "conservative" ]; then
cp -pf "/usr/lib/modules/acpi_cpufreq.ko" "/tmpRoot/usr/lib/modules/acpi_cpufreq.ko"
fi
[ "${2}" != "schedutil" ] && cp -pf "/usr/lib/modules/cpufreq_${2}.ko" "/tmpRoot/usr/lib/modules/cpufreq_${2}.ko" [ "${2}" != "schedutil" ] && cp -pf "/usr/lib/modules/cpufreq_${2}.ko" "/tmpRoot/usr/lib/modules/cpufreq_${2}.ko"
mkdir -p "/tmpRoot/usr/lib/systemd/system" mkdir -p "/tmpRoot/usr/lib/systemd/system"
@ -21,7 +23,7 @@ if [ "${1}" = "late" ]; then
{ {
echo "[Unit]" echo "[Unit]"
echo "Description=Enable CPU Freq scaling" echo "Description=Enable CPU Freq scaling"
echo "After=syno-volume.target syno-space.target" echo "After=multi-user.target"
echo echo
echo "[Service]" echo "[Service]"
echo "User=root" echo "User=root"
@ -35,18 +37,19 @@ if [ "${1}" = "late" ]; then
} >"${DEST}" } >"${DEST}"
mkdir -p /tmpRoot/usr/lib/systemd/system/multi-user.target.wants mkdir -p /tmpRoot/usr/lib/systemd/system/multi-user.target.wants
ln -vsf /usr/lib/systemd/system/cpufreqscaling.service /tmpRoot/usr/lib/systemd/system/multi-user.target.wants/cpufreqscaling.service ln -vsf /usr/lib/systemd/system/cpufreqscaling.service /tmpRoot/usr/lib/systemd/system/multi-user.target.wants/cpufreqscaling.service
if [ "${2}" = "schedutil" ] || [ "${2}" = "ondemand" ] || [ "${2}" = "conservative" ]; then
if [ ! -f /tmpRoot/usr/syno/etc/esynoscheduler/esynoscheduler.db ]; then if [ ! -f /tmpRoot/usr/syno/etc/esynoscheduler/esynoscheduler.db ]; then
echo "copy esynoscheduler.db" echo "copy esynoscheduler.db"
mkdir -p /tmpRoot/usr/syno/etc/esynoscheduler mkdir -p /tmpRoot/usr/syno/etc/esynoscheduler
cp -pf /addons/esynoscheduler.db /tmpRoot/usr/syno/etc/esynoscheduler/esynoscheduler.db cp -pf /addons/esynoscheduler.db /tmpRoot/usr/syno/etc/esynoscheduler/esynoscheduler.db
fi fi
echo "insert scaling... task to esynoscheduler.db" echo "insert scaling... task to esynoscheduler.db"
export LD_LIBRARY_PATH=/tmpRoot/bin:/tmpRoot/lib export LD_LIBRARY_PATH=/tmpRoot/bin:/tmpRoot/lib
/tmpRoot/bin/sqlite3 /tmpRoot/usr/syno/etc/esynoscheduler/esynoscheduler.db <<EOF /tmpRoot/bin/sqlite3 /tmpRoot/usr/syno/etc/esynoscheduler/esynoscheduler.db <<EOF
DELETE FROM task WHERE task_name LIKE 'CPUFreqscaling'; DELETE FROM task WHERE task_name LIKE 'CPUFreqscaling';
INSERT INTO task VALUES('CPUFreqscaling', '', 'bootup', '', 0, 0, 0, 0, '', 0, '/usr/sbin/scaling.sh ${2}', 'script', '{}', '', '', '{}', '{}'); INSERT INTO task VALUES('CPUFreqscaling', '', 'bootup', '', 0, 0, 0, 0, '', 0, '/usr/sbin/scaling.sh ${2}', 'script', '{}', '', '', '{}', '{}');
EOF EOF
fi
elif [ "${1}" = "uninstall" ]; then elif [ "${1}" = "uninstall" ]; then
echo "Installing cpufreqscalingscaling - ${1}" echo "Installing cpufreqscalingscaling - ${1}"