diff --git a/cpufreqscaling/all/usr/sbin/scaling.sh b/cpufreqscaling/all/usr/sbin/scaling.sh index d864dfa..e28b1ad 100755 --- a/cpufreqscaling/all/usr/sbin/scaling.sh +++ b/cpufreqscaling/all/usr/sbin/scaling.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Copyright (C) 2023 AuxXxilium +# Copyright (C) 2024 AuxXxilium # # This is free software, licensed under the MIT License. # See /LICENSE for more information. @@ -9,41 +9,22 @@ # Make things safer set -euo pipefail -# Get cpu cores count minus 1, to allow maping from 0 -cpucorecount=$(cat /proc/cpuinfo | grep processor | wc -l) -cpucorecount=$((cpucorecount - 1)) -error=0 - # Load the correct cpufreq module -if [ "${1}" = "ondemand" ] || [ "${1}" = "conservative" ]; then - if [ -f "/usr/lib/modules/cpufreq_${1}.ko" ]; then - insmod /usr/lib/modules/cpufreq_${1}.ko || true - echo "CPUFreqScaling: cpufreq_${1} loaded" - else - echo "CPUFreqScaling: cpufreq_${1} not found" - error=1 - break - fi +cerror=0 +if [ "${1}" == "ondemand" ] || [ "${1}" == "conservative" ]; then + insmod /usr/lib/modules/cpufreq_${1}.ko || cerror=1 +fi +# Set correct cpufreq governor to allow frequency scaling +if [ "${governor}" != "${1}" ]; then + echo "${1}" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor fi -# Deamonize the main function... -for i in $(seq 0 ${cpucorecount}); do - governor=$(cat /sys/devices/system/cpu/cpu${i}/cpufreq/scaling_governor) - # Set correct cpufreq governor to allow frequency scaling - if [ "${governor}" != "${1}" ]; then - echo "${1}" >/sys/devices/system/cpu/cpu${i}/cpufreq/scaling_governor - fi -done sleep 10 # Check if the governor is set correctly -for i in $(seq 0 ${cpucorecount}); do - governor=$(cat /sys/devices/system/cpu/cpu${i}/cpufreq/scaling_governor) - if [ "${governor}" = "${1}" ]; then - echo "CPUFreqScaling: Governor set to ${1}" - else - echo "CPUFreqScaling: Failed to set governor to ${1}" - error=1 - break - fi -done -[ ${error} -eq 1 ] && exit 1 -exit 0 \ No newline at end of file +verifygovernor=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor) +if [ "${verifygovernor}" == "${1}" ]; then + echo "CPUFreqScaling: Governor set to ${1}" +else + echo "CPUFreqScaling: Failed to set governor to ${1}" + cerror=1 +fi +[ ${cerror} -eq 1 ] && exit 1 || exit 0 \ No newline at end of file diff --git a/cpufreqscaling/install.sh b/cpufreqscaling/install.sh index e55a193..88638c2 100755 --- a/cpufreqscaling/install.sh +++ b/cpufreqscaling/install.sh @@ -36,6 +36,19 @@ WantedBy=multi-user.target EOF mkdir -vp /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 + + if [ ! -f /tmpRoot/usr/syno/etc/esynoscheduler/esynoscheduler.db ]; then + echo "copy esynoscheduler.db" + mkdir -p /tmpRoot/usr/syno/etc/esynoscheduler + cp -vf /addons/esynoscheduler.db /tmpRoot/usr/syno/etc/esynoscheduler/esynoscheduler.db + fi + echo "insert scaling... task to esynoscheduler.db" + export LD_LIBRARY_PATH=/tmpRoot/bin:/tmpRoot/lib + /tmpRoot/bin/sqlite3 /tmpRoot/usr/syno/etc/esynoscheduler/esynoscheduler.db <