arc-addons/powersched/install.sh
AuxXxilium 886f15f4c2 tree: rework
Signed-off-by: AuxXxilium <info@auxxxilium.tech>
2024-11-08 19:42:33 +01:00

28 lines
1.3 KiB
Bash
Executable File

#!/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/"
cp -pf "${0}" "/tmpRoot/usr/arc/addons/"
[ ! -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"
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
echo "* * * * * root /usr/sbin/powersched #arpl powersched addon" >>/tmpRoot/etc/crontab
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