misc: update

Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
AuxXxilium 2024-06-19 22:54:27 +02:00
parent 039bba41c4
commit 64f7bc5d29
2 changed files with 53 additions and 16 deletions

29
misc/all/usr/sbin/governor.sh Executable file
View File

@ -0,0 +1,29 @@
#!/usr/bin/env ash
#
# Copyright (C) 2023 AuxXxilium <https://github.com/AuxXxilium>
#
# This is free software, licensed under the MIT License.
# See /LICENSE for more information.
#
PLATFORM="$(/bin/get_key_value /etc.defaults/synoinfo.conf unique | cut -d"_" -f2)"
CPUCORE=$(cat /proc/cpuinfo 2>/dev/null | grep processor | wc -l)
while true; do
CPUCORE=$((CPUCORE - 1))
if [ "${PLATFORM}" == "eypc7002" ]; then
if grep -qw "schedutil" /sys/devices/system/cpu/cpu${CPUCORE}/cpufreq/scaling_available_governors; then
echo "schedutil" >/sys/devices/system/cpu/cpu${CPUCORE}/cpufreq/scaling_available_governors
else
echo "performance" >/sys/devices/system/cpu/cpu${CPUCORE}/cpufreq/scaling_available_governors
fi
else
if grep -qw "ondemand" /sys/devices/system/cpu/cpu${CPUCORE}/cpufreq/scaling_available_governors; then
echo "ondemand" >/sys/devices/system/cpu/cpu${CPUCORE}/cpufreq/scaling_available_governors
else
echo "performance" >/sys/devices/system/cpu/cpu${CPUCORE}/cpufreq/scaling_available_governors
fi
fi
if [ ${CPUCORE} -eq 0 ]; then
break
fi
done

View File

@ -132,22 +132,30 @@ elif [ "${1}" = "late" ]; then
echo "CPU supports CPU Performance Scaling, enabling"
sed -i 's/^# acpi-cpufreq/acpi-cpufreq/g' /tmpRoot/usr/lib/modules-load.d/70-cpufreq-kernel.conf
cp -vf /usr/lib/modules/cpufreq_* /tmpRoot/usr/lib/modules/
PLATFORM="$(/bin/get_key_value /etc.defaults/synoinfo.conf unique | cut -d"_" -f2)"
while read -r CPU; do
if [ "${PLATFORM}" == "eypc7002" ]; then
if grep -qw "schedutil" /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors; then
echo "schedutil" > /tmpRoot${CPU}/cpufreq/scaling_governor
else
echo "performance" > /tmpRoot${CPU}/cpufreq/scaling_governor
fi
else
if grep -qw "ondemand" /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors; then
echo "ondemand" > /tmpRoot${CPU}/cpufreq/scaling_governor
else
echo "performance" > /tmpRoot${CPU}/cpufreq/scaling_governor
fi
fi
done < <(ls -d /sys/devices/system/cpu/cpu[0-9]*)
# copy cpu governor
echo "Installing Set CPU Governor - ${1}"
cp -vf /usr/sbin/governor.sh /tmpRoot/usr/sbin/governor.sh
mkdir -p "/tmpRoot/usr/lib/systemd/system"
DEST="/tmpRoot/usr/lib/systemd/system/governor.service"
echo "[Unit]" >${DEST}
echo "Description=Set CPU Governor" >>${DEST}
echo "DefaultDependencies=no" >>${DEST}
echo "IgnoreOnIsolate=true" >>${DEST}
echo "After=multi-user.target" >>${DEST}
echo >>${DEST}
echo "[Service]" >>${DEST}
echo "User=root" >>${DEST}
echo "Restart=always" >>${DEST}
echo "RestartSec=30" >>${DEST}
echo "ExecStart=/usr/sbin/governor.sh" >>${DEST}
echo >>${DEST}
echo "[X-Synology]" >>${DEST}
echo "Author=Virtualization Team" >>${DEST}
mkdir -vp /tmpRoot/usr/lib/systemd/system/multi-user.target.wants
ln -vsf /usr/lib/systemd/system/governor.service /tmpRoot/usr/lib/systemd/system/multi-user.target.wants/governor.service
fi
fi
umount /sys