Skip to content

Commit

Permalink
add cron jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
B3H1Z committed Sep 23, 2023
1 parent 862c268 commit 5d8cea5
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,25 @@ function stop_bot() {
pkill -15 -f hiddifyTelegramBot.py
}

add_cron_job_if_not_exists() {
local cron_job="$1"
local current_crontab

# Normalize the cron job formatting (remove extra spaces)
cron_job=$(echo "$cron_job" | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')

# Check if the cron job already exists in the current user's crontab
current_crontab=$(crontab -l 2>/dev/null || true)

if [[ -z "$current_crontab" ]]; then
# No existing crontab, so add the new cron job
(echo "$cron_job") | crontab -
elif ! (echo "$current_crontab" | grep -Fq "$cron_job"); then
# Cron job doesn't exist, so append it to the crontab
(echo "$current_crontab"; echo "$cron_job") | crontab -
fi
}

# Function to reinstall the bot
function reinstall_bot() {
display_message "${YELLOW}This version is deprecated, and you need to reinstall the bot.${RESET}"
Expand Down

0 comments on commit 5d8cea5

Please sign in to comment.