mirror of
https://github.com/9technologygroup/patchmon.net.git
synced 2025-11-08 07:52:21 +00:00
made the crontab installation safe as opposed to nuking it - spotted by thespad
This commit is contained in:
@@ -160,12 +160,22 @@ fi
|
|||||||
|
|
||||||
# Setup crontab for automatic package status updates
|
# Setup crontab for automatic package status updates
|
||||||
info "⏰ Setting up automatic package status update every $UPDATE_INTERVAL minutes..."
|
info "⏰ Setting up automatic package status update every $UPDATE_INTERVAL minutes..."
|
||||||
|
|
||||||
|
# Check if patchmon cron job already exists
|
||||||
|
PATCHMON_CRON_EXISTS=$(crontab -l 2>/dev/null | grep -c "patchmon-agent.sh update" || true)
|
||||||
|
|
||||||
|
if [[ $PATCHMON_CRON_EXISTS -gt 0 ]]; then
|
||||||
|
info " Existing PatchMon cron job found, removing old entry..."
|
||||||
|
# Remove existing patchmon cron entries and preserve other entries
|
||||||
|
(crontab -l 2>/dev/null | grep -v "patchmon-agent.sh update") | crontab -
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ $UPDATE_INTERVAL -eq 60 ]]; then
|
if [[ $UPDATE_INTERVAL -eq 60 ]]; then
|
||||||
# Hourly updates
|
# Hourly updates - safely append to existing crontab
|
||||||
echo "0 * * * * /usr/local/bin/patchmon-agent.sh update >/dev/null 2>&1" | crontab -
|
(crontab -l 2>/dev/null; echo "0 * * * * /usr/local/bin/patchmon-agent.sh update >/dev/null 2>&1") | crontab -
|
||||||
else
|
else
|
||||||
# Custom interval updates
|
# Custom interval updates - safely append to existing crontab
|
||||||
echo "*/$UPDATE_INTERVAL * * * * /usr/local/bin/patchmon-agent.sh update >/dev/null 2>&1" | crontab -
|
(crontab -l 2>/dev/null; echo "*/$UPDATE_INTERVAL * * * * /usr/local/bin/patchmon-agent.sh update >/dev/null 2>&1") | crontab -
|
||||||
fi
|
fi
|
||||||
|
|
||||||
success "🎉 PatchMon Agent installation complete!"
|
success "🎉 PatchMon Agent installation complete!"
|
||||||
|
|||||||
Reference in New Issue
Block a user