mirror of
https://github.com/AuxXxilium/arc-addons.git
synced 2024-11-23 21:50:52 +07:00
886f15f4c2
Signed-off-by: AuxXxilium <info@auxxxilium.tech>
58 lines
2.1 KiB
Bash
Executable File
58 lines
2.1 KiB
Bash
Executable File
#!/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.
|
|
#
|
|
|
|
if [ "${1}" = "late" ]; then
|
|
echo "Installing cpufreqscalingscaling - ${1}"
|
|
mkdir -p "/tmpRoot/usr/arc/addons/"
|
|
cp -pf "${0}" "/tmpRoot/usr/arc/addons/"
|
|
|
|
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
|
|
cp -pf "/usr/lib/modules/acpi_cpufreq.ko" "/tmpRoot/usr/lib/modules/acpi_cpufreq.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"
|
|
DEST="/tmpRoot/usr/lib/systemd/system/cpufreqscaling.service"
|
|
cat <<EOF >${DEST}
|
|
[Unit]
|
|
Description=Enable CPU Freq scaling
|
|
After=syno-volume.target syno-space.target
|
|
|
|
[Service]
|
|
User=root
|
|
Type=simple
|
|
Restart=on-failure
|
|
RestartSec=10
|
|
ExecStart=/usr/sbin/scaling.sh ${2}
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
EOF
|
|
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
|
|
|
|
if [ ! -f /tmpRoot/usr/syno/etc/esynoscheduler/esynoscheduler.db ]; then
|
|
echo "copy esynoscheduler.db"
|
|
mkdir -p /tmpRoot/usr/syno/etc/esynoscheduler
|
|
cp -pf /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 <<EOF
|
|
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', '{}', '', '', '{}', '{}');
|
|
EOF
|
|
|
|
elif [ "${1}" = "uninstall" ]; then
|
|
echo "Installing cpufreqscalingscaling - ${1}"
|
|
|
|
rm -f "/tmpRoot/usr/lib/systemd/system/multi-user.target.wants/cpufreqscaling.service"
|
|
rm -f "/tmpRoot/usr/lib/systemd/system/cpufreqscaling.service"
|
|
|
|
rm -f /tmpRoot/usr/sbin/scaling.sh
|
|
fi |