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
|
|
|
|
echo "Installing addon powersched - ${1}"
|
|
|
|
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
|
|
|
[ ! -f "/tmpRoot/usr/sbin/powersched.bak" -a -f "/tmpRoot/usr/sbin/powersched" ] && cp -pf "/tmpRoot/usr/sbin/powersched" "/tmpRoot/usr/sbin/powersched.bak"
|
|
|
|
cp -pf "/usr/sbin/powersched" "/tmpRoot/usr/sbin/powersched"
|
2024-05-05 06:16:56 +07:00
|
|
|
chmod 755 "/tmpRoot/usr/sbin/powersched"
|
|
|
|
# Clean old entries
|
|
|
|
[ ! -f "/tmpRoot/etc/crontab.bak" -a -f "/tmpRoot/etc/crontab" ] && cp -f "/tmpRoot/etc/crontab" "/tmpRoot/etc/crontab.bak"
|
|
|
|
SED_PATH='/tmpRoot/usr/bin/sed'
|
|
|
|
${SED_PATH} -i '/\/usr\/sbin\/powersched/d' /tmpRoot/etc/crontab
|
|
|
|
# Add line to crontab, execute each minute
|
2024-08-23 04:34:35 +07:00
|
|
|
echo "* * * * * root /usr/sbin/powersched #arpl powersched addon" >>/tmpRoot/etc/crontab
|
2024-05-05 06:16:56 +07:00
|
|
|
elif [ "${1}" = "uninstall" ]; then
|
|
|
|
echo "Installing addon powersched - ${1}"
|
|
|
|
|
|
|
|
[ -f "/tmpRoot/usr/sbin/powersched.bak" ] && mv -f "/tmpRoot/usr/sbin/powersched.bak" "/tmpRoot/usr/sbin/powersched"
|
|
|
|
[ -f "/tmpRoot/etc/crontab.bak" ] && mv -f "/tmpRoot/etc/crontab.bak" "/tmpRoot/etc/crontab"
|
|
|
|
fi
|