Stop all cron jobs before upgrading

This commit is contained in:
Whispering Wind
2025-01-03 20:55:24 +03:30
committed by GitHub
parent 516f029643
commit 25167efb1e

View File

@ -14,6 +14,10 @@ FILES=(
"/etc/hysteria/core/scripts/normalsub/.env" "/etc/hysteria/core/scripts/normalsub/.env"
) )
echo "Backing up and Stopping all cron jobs"
crontab -l > /tmp/crontab_backup
crontab -r
echo "Backing up files to $TEMP_DIR" echo "Backing up files to $TEMP_DIR"
for FILE in "${FILES[@]}"; do for FILE in "${FILES[@]}"; do
mkdir -p "$TEMP_DIR/$(dirname "$FILE")" mkdir -p "$TEMP_DIR/$(dirname "$FILE")"
@ -84,15 +88,8 @@ else
echo "Upgrade failed: hysteria-server.service is not active" echo "Upgrade failed: hysteria-server.service is not active"
fi fi
CRON_JOB="0 3 */3 * * /bin/bash -c 'source /etc/hysteria/hysteria2_venv/bin/activate && python3 /etc/hysteria/core/cli.py restart-hysteria2' >/dev/null 2>&1" echo "Restoring cron jobs"
crontab /tmp/crontab_backup
if crontab -l | grep -Fxq "$CRON_JOB"; then
echo "Cron job already exists."
else
echo "Adding cron job."
(crontab -l; echo "$CRON_JOB") | crontab -
echo "Cron job added successfully."
fi
chmod +x menu.sh chmod +x menu.sh
./menu.sh ./menu.sh