1
0
Fork 0

changes related to maintenance.sh

- cleanup, use a global log-file
  - add a check for zpool existence; send a mail otherwise
  - remove transmission service
  - if restarting *-chitragupta, restart *-govinda too
This commit is contained in:
Pratham Patel 2022-10-13 18:13:27 +05:30
parent 8037935678
commit 60f49b1357
2 changed files with 39 additions and 6 deletions

View File

@ -1,13 +1,34 @@
#!/usr/bin/env bash
CUSTOM_LOGFILE=$HOME/.log/cron/pratham/log
if [[ -f /usr/sbin/zpool ]]; then
if [[ ! -d /trayimurti/containers &&
! -d /trayimurti/sanaatana-dharma &&
! -d /trayimurti/torrents &&
! -d /trayimurti/containers/volumes ]]; then
CURR_DATE=$(date +'(UTC%:::z) %Y/%m/%d %H:%M:%S')
MAILCONTENT=$HOME/.scripts/_bluefeds/mail/containers/missing_zpool.mailcontents
echo "$CURR_DATE: \"missing_zpool\"" >> $CUSTOM_LOGFILE
# send e-mail about the service that was restarted
/usr/sbin/ssmtp thefirst1322@gmail.com < $MAILCONTENT
# since the zool which has container volumes is not mounted, exit
exit 1
fi
fi
# systemd services for each of my podman container
CONTAINER_SERVICES=(
"container-nextcloud-govinda.service" \
"container-gitea-govinda.service" \
"container-gitea-chitragupta.service" \
"container-nextcloud-chitragupta.service" \
"container-hugo-mahayogi.service" \
"container-gitea-govinda.service" \
"container-hugo-vaikunthnatham.service" \
"container-hugo-mahayogi.service" \
"container-nextcloud-chitragupta.service" \
"container-nextcloud-govinda.service" \
"container-caddy-vishwambhar.service" \
)
@ -45,8 +66,17 @@ if [[ "$UPTIME_MINUTES" -gt "$UPTIME_CMP" ]]; then
# what should be in the e-mail _IF_ the service is restarted?
MAILCONTENT=$HOME/.scripts/_bluefeds/mail/containers/"$INDV_SERVICE".mailcontents
# restart $INDV_SERVICE _AND_ container-caddy-vishwambhar.service
systemctl --user start "$INDV_SERVICE" && systemctl --user restart container-caddy-vishwambhar.service && echo "$CURR_DATE: \"$INDV_SERVICE\"" >> $HOME/.log/cron/pratham/log
if [[ "$INDV_SERVICE" == "container-nextcloud-chitragupta.service" ]]; then
systemctl --user start "$INDV_SERVICE" && systemctl --user restart container-nextcloud-govinda.service && echo "$CURR_DATE: \"$INDV_SERVICE\"" >> $CUSTOM_LOGFILE
elif "$INDV_SERVICE" == "container-gitea-chitragupta.service" ]]; then
systemctl --user start "$INDV_SERVICE" && systemctl --user restart container-gitea-govinda.service && echo "$CURR_DATE: \"$INDV_SERVICE\"" >> $CUSTOM_LOGFILE
else
# restart $INDV_SERVICE _AND_ container-caddy-vishwambhar.service
systemctl --user start "$INDV_SERVICE" && systemctl --user restart container-caddy-vishwambhar.service && echo "$CURR_DATE: \"$INDV_SERVICE\"" >> $CUSTOM_LOGFILE
fi
# send e-mail about the service that was restarted
/usr/sbin/ssmtp thefirst1322@gmail.com < $MAILCONTENT

View File

@ -0,0 +1,3 @@
To: thefirst1322@gmail.com
From: DOWNTIME ALERT (bluefeds)
Subject: [URGENT] MISSING ZPOOL