From b495eb0c692ae25cd565c9c8b4e6e4d26b3fd4d7 Mon Sep 17 00:00:00 2001 From: Cyber Date: Thu, 25 Jul 2024 06:03:41 +0000 Subject: [PATCH] refactor: move `notify.sh` script to `/var/tools/container-expire-notifs` --- enable-expire-notifs.sh | 7 +++++-- notify.sh | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/enable-expire-notifs.sh b/enable-expire-notifs.sh index 809efd5..7e509ea 100755 --- a/enable-expire-notifs.sh +++ b/enable-expire-notifs.sh @@ -13,7 +13,10 @@ if [[ hello -ne 200 ]]; then exit 1 fi -echo $API_KEY > .api-key +mkdir /var/tools/container-expire-notifs +cp /root/container-expire-notifs/notify.sh /var/tools/container-expire-notifs/notify.sh + +echo $API_KEY > /var/tools/container-expire-notifs/.api-key [ ! which at ] && sudo apt install at @@ -22,7 +25,7 @@ date=$(curl -sH "x-ssh-auth: $API_KEY" $API_HOST/time | grep -o '"expireDate":"[ [ if ! grep atd /start.sh ] sed -i -e 's/#s2lmain/atd/g' /start.sh atd -at -t $(date -d $date +'%Y%m%d%H%M') -f /root/container-expire-notifs/notify.sh +at -t $(date -d $date +'%Y%m%d%H%M') -f /var/tools/container-expire-notifs/notify.sh notif "Container expiration notifications brought back successfully!" notif "**WARNING**: If your container is off you may not receive the reminder" diff --git a/notify.sh b/notify.sh index f10cdae..697a22f 100755 --- a/notify.sh +++ b/notify.sh @@ -4,4 +4,4 @@ API_KEY=$(cat .api-key) notif "Hello, your container at SSH.SURF has hit its expire date, if not extended before 6PM EST the container will be removed automatically. Use /extend to gain another 7 days." date=$(curl -sH "x-ssh-auth: $API_KEY" $API_HOST/time | grep -o '"expireDate":"[^"]*' | grep -o '[^"]*$') -at -t $(date -d $date +'%Y%m%d%H%M' -d "$end_date+7 days") -f /root/container-expire-notifs/notify.sh +at -t $(date -d $date +'%Y%m%d%H%M' -d "$end_date+7 days") -f /var/tools/container-expire-notifs/notify.sh