mirror of
https://github.com/fankes/beszel.git
synced 2025-10-18 17:29:28 +08:00
[Bug] Update install script to use crontab on Alpine (#1136)
* add cron * update the install script
This commit is contained in:
@@ -216,11 +216,11 @@ if [ "$UNINSTALL" = true ]; then
|
|||||||
echo "Removing the OpenRC service files..."
|
echo "Removing the OpenRC service files..."
|
||||||
rm -f /etc/init.d/beszel-agent
|
rm -f /etc/init.d/beszel-agent
|
||||||
|
|
||||||
# Remove the update service if it exists
|
# Remove the daily update cron job if it exists
|
||||||
echo "Removing the daily update service..."
|
echo "Removing the daily update cron job..."
|
||||||
rc-service beszel-agent-update stop 2>/dev/null
|
if crontab -u root -l 2>/dev/null | grep -q "beszel-agent.*update"; then
|
||||||
rc-update del beszel-agent-update default 2>/dev/null
|
crontab -u root -l 2>/dev/null | grep -v "beszel-agent.*update" | crontab -u root -
|
||||||
rm -f /etc/init.d/beszel-agent-update
|
fi
|
||||||
|
|
||||||
# Remove log files
|
# Remove log files
|
||||||
echo "Removing log files..."
|
echo "Removing log files..."
|
||||||
@@ -530,28 +530,13 @@ EOF
|
|||||||
[Yy]*)
|
[Yy]*)
|
||||||
echo "Setting up daily automatic updates for beszel-agent..."
|
echo "Setting up daily automatic updates for beszel-agent..."
|
||||||
|
|
||||||
cat >/etc/init.d/beszel-agent-update <<EOF
|
# Create cron job to run beszel-agent update command daily at midnight
|
||||||
#!/sbin/openrc-run
|
if ! crontab -u root -l 2>/dev/null | grep -q "beszel-agent.*update"; then
|
||||||
|
(crontab -u root -l 2>/dev/null; echo "0 0 * * * /opt/beszel-agent/beszel-agent update >/dev/null 2>&1") | crontab -u root -
|
||||||
|
fi
|
||||||
|
|
||||||
name="beszel-agent-update"
|
printf "\nAutomatic daily updates have been enabled via cron job.\n"
|
||||||
description="Update beszel-agent if needed"
|
printf "The beszel-agent update command will run daily at midnight.\n"
|
||||||
|
|
||||||
depend() {
|
|
||||||
need beszel-agent
|
|
||||||
}
|
|
||||||
|
|
||||||
start() {
|
|
||||||
ebegin "Checking for beszel-agent updates"
|
|
||||||
/opt/beszel-agent/beszel-agent update
|
|
||||||
eend $?
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
chmod +x /etc/init.d/beszel-agent-update
|
|
||||||
rc-update add beszel-agent-update default
|
|
||||||
rc-service beszel-agent-update start
|
|
||||||
|
|
||||||
printf "\nAutomatic daily updates have been enabled.\n"
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user