arc-addons/sensors/install.sh

50 lines
2.0 KiB
Bash
Raw Permalink Normal View History

#!/usr/bin/env ash
#
# Copyright (C) 2023 AuxXxilium <https://github.com/AuxXxilium> and Ing <https://github.com/wjz304>
#
# This is free software, licensed under the MIT License.
# See /LICENSE for more information.
#
if [ "${1}" = "late" ]; then
echo "Installing addon sensors - ${1}"
mkdir -p "/tmpRoot/usr/arc/addons/"
cp -pf "${0}" "/tmpRoot/usr/arc/addons/"
tar -zxf /addons/sensors-7.1.tgz -C /tmpRoot/usr/
mv -f /tmpRoot/usr/etc/sensors* /tmpRoot/etc
cp -pf /usr/bin/arc-sensors.sh /tmpRoot/usr/bin/arc-sensors.sh
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 sensors task to esynoscheduler.db"
export LD_LIBRARY_PATH=/tmpRoot/bin:/tmpRoot/lib
if echo "SELECT * FROM task;" | /tmpRoot/bin/sqlite3 /tmpRoot/usr/syno/etc/esynoscheduler/esynoscheduler.db | grep -q "Fancontrol||bootup||1|0|0|0||0|"; then
echo "Fancontrol task already exists and it is enabled"
else
/tmpRoot/bin/sqlite3 /tmpRoot/usr/syno/etc/esynoscheduler/esynoscheduler.db <<EOF
DELETE FROM task WHERE task_name LIKE 'Fancontrol';
INSERT INTO task VALUES('Fancontrol', '', 'bootup', '', 0, 0, 0, 0, '', 0, '
# Please manually adjust the value in /etc/fancontrol.
# Or use pwmconfig to generate /etc/fancontrol interactively.
/usr/bin/arc-sensors.sh
', 'script', '{}', '', '', '{}', '{}');
EOF
fi
elif [ "${1}" = "uninstall" ]; then
echo "Installing addon sensors - ${1}"
rm -rf /tmpRoot/etc/fancontrol
rm -f /tmpRoot/usr/bin/arc-sensors.sh
if [ -f /tmpRoot/usr/syno/etc/esynoscheduler/esynoscheduler.db ]; then
echo "delete sensors task from 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 'Fancontrol';
EOF
fi
fi