From ac002ae0cf2f528e98b9cba7504ceeccaf424863 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Wed, 31 Jul 2019 17:50:22 +0530 Subject: [PATCH] Add service and timer for androidx-release-watcher Signed-off-by: Harsh Shandilya --- androidx-release-watcher.service | 10 ++++++++++ release-watcher-recent.timer | 12 ++++++++++++ update.sh | 20 ++++++++++++++++++-- 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 androidx-release-watcher.service create mode 100644 release-watcher-recent.timer diff --git a/androidx-release-watcher.service b/androidx-release-watcher.service new file mode 100644 index 0000000..50110b1 --- /dev/null +++ b/androidx-release-watcher.service @@ -0,0 +1,10 @@ +[Unit] +Description=Telegram notifier service for androidx-release-watcher +Wants=release-watcher-recent.timer + +[Service] +WorkingDirectory=/home/bot/androidx-release-watcher +ExecStart=/home/bot/androidx-release-watcher/venv/bin/python telegram_notifier.py + +[Install] +WantedBy=multi-user.target diff --git a/release-watcher-recent.timer b/release-watcher-recent.timer new file mode 100644 index 0000000..b39101f --- /dev/null +++ b/release-watcher-recent.timer @@ -0,0 +1,12 @@ +[Unit] +Description=Run shopify-recent every 24 hours with a 30 minute leeway +Requires=androidx-release-watcher.service + +[Timer] +Unit=androidx-release-watcher.service +OnUnitInactiveSec=24h +RandomizedDelaySec=15m +AccuracySec=1s + +[Install] +WantedBy=timers.target diff --git a/update.sh b/update.sh index 7d4fb5c..8c678d2 100755 --- a/update.sh +++ b/update.sh @@ -8,7 +8,8 @@ function prettyPrint { } # Grab all service names -declare -a services=('caddy' 'gitea' 'horbiswalls-bot' 'mirror-bot' 'uno-bot') +declare -a services=('androidx-release-watcher' 'caddy' 'gitea' 'horbiswalls-bot' 'mirror-bot' 'uno-bot') +declare -a timers=('release-watcher-recent') # Now loop through each service and install it for service in "${services[@]}"; do @@ -19,9 +20,24 @@ for service in "${services[@]}"; do sudo cp -v "${service}.service" /etc/systemd/system/ sudo systemctl daemon-reload prettyPrint "Restarting ${service}" - sudo service "${service}" restart + sudo systemctl restart "${service}" if [ ! -f "/etc/systemd/system/multi-user.target.wants/${service}.service" ]; then prettyPrint "Enabling ${service}" sudo systemctl enable "${service}" fi done + +for timer in "${timers[@]}"; do + if [ "${1}" ] && [ "${timer}" != "${1}" ]; then + continue + fi + prettyPrint "Installing ${timer}" + sudo cp -v "${timer}.timer" /etc/systemd/system/ + sudo systemctl daemon-reload + prettyPrint "Restarting ${timer}" + sudo systemctl restart "${timer}".timer + if [ ! -f "/etc/systemd/system/multi-user.target.wants/${timer}.timer" ]; then + prettyPrint "Enabling ${timer}" + sudo systemctl enable "${timer}".timer + fi +done