2024-05-05 06:16:56 +07:00
|
|
|
#!/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
|
2024-06-14 00:27:17 +07:00
|
|
|
echo "Installing addon rebootto... - ${1}"
|
2024-05-05 06:16:56 +07:00
|
|
|
mkdir -p "/tmpRoot/usr/arc/addons/"
|
2024-11-09 01:34:54 +07:00
|
|
|
cp -pf "${0}" "/tmpRoot/usr/arc/addons/"
|
2024-05-05 06:16:56 +07:00
|
|
|
|
2024-11-09 01:34:54 +07:00
|
|
|
cp -pf /usr/bin/loader-reboot.sh /tmpRoot/usr/bin
|
|
|
|
cp -pf /usr/bin/grub-editenv /tmpRoot/usr/bin
|
2024-05-05 06:16:56 +07:00
|
|
|
|
|
|
|
if [ ! -f /tmpRoot/usr/syno/etc/esynoscheduler/esynoscheduler.db ]; then
|
|
|
|
echo "copy esynoscheduler.db"
|
|
|
|
mkdir -p /tmpRoot/usr/syno/etc/esynoscheduler
|
2024-11-09 01:34:54 +07:00
|
|
|
cp -pf /addons/esynoscheduler.db /tmpRoot/usr/syno/etc/esynoscheduler/esynoscheduler.db
|
2024-05-05 06:16:56 +07:00
|
|
|
fi
|
2024-06-14 00:27:17 +07:00
|
|
|
echo "insert rebootto... task to esynoscheduler.db"
|
2024-05-05 06:16:56 +07:00
|
|
|
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 'RebootToLoader';
|
|
|
|
INSERT INTO task VALUES('RebootToLoader', '', 'shutdown', '', 0, 0, 0, 0, '', 0, '/usr/bin/loader-reboot.sh "config"', 'script', '{}', '', '', '{}', '{}');
|
2024-06-14 00:27:17 +07:00
|
|
|
DELETE FROM task WHERE task_name LIKE 'RebootToUpdate';
|
|
|
|
INSERT INTO task VALUES('RebootToUpdate', '', 'shutdown', '', 0, 0, 0, 0, '', 0, '/usr/bin/loader-reboot.sh "update"', 'script', '{}', '', '', '{}', '{}');
|
2024-05-05 06:16:56 +07:00
|
|
|
EOF
|
|
|
|
elif [ "${1}" = "uninstall" ]; then
|
2024-06-14 00:27:17 +07:00
|
|
|
echo "Installing addon rebootto... - ${1}"
|
2024-05-05 06:16:56 +07:00
|
|
|
|
|
|
|
rm -f /tmpRoot/usr/bin/loader-reboot.sh
|
|
|
|
rm -f /tmpRoot/usr/bin/grub-editenv
|
|
|
|
|
|
|
|
if [ -f /tmpRoot/usr/syno/etc/esynoscheduler/esynoscheduler.db ]; then
|
2024-06-14 00:27:17 +07:00
|
|
|
echo "delete rebootto... task from esynoscheduler.db"
|
2024-05-05 06:16:56 +07:00
|
|
|
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 'RebootToLoader';
|
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
fi
|