From 9df9925c7263055f88e65c3058899850ced818b8 Mon Sep 17 00:00:00 2001 From: Cyber Date: Wed, 19 Jun 2024 08:35:24 +0000 Subject: [PATCH] Brought it back --- .gitignore | 1 + enable-expire-notifs.sh | 14 ++++++++++++++ notify.sh | 7 +++++++ 3 files changed, 22 insertions(+) create mode 100644 .gitignore create mode 100755 notify.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1c6915e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.api-key diff --git a/enable-expire-notifs.sh b/enable-expire-notifs.sh index b7fa48f..81e6a8e 100755 --- a/enable-expire-notifs.sh +++ b/enable-expire-notifs.sh @@ -12,3 +12,17 @@ if [[ hello -ne 200 ]]; then echo "token not valid, exiting" exit 1 fi + +echo $API_KEY > .api-key + +[ ! which at ] && sudo apt install at + +date=$(curl -sH "x-ssh-auth: $API_KEY" $API_HOST/time | grep -o '"expireDate":"[^"]*' | grep -o '[^"]*$') + +echo atd >> /start.sh +atd + +at -t $(date -d $date +'%Y%m%d%H%M') -f /root/container-expire-notifs/notify.sh + +notif "Container expiration notifications brought back successfully!" +notif "**WRNING**: If your conainer is off you may not receive the reminder" diff --git a/notify.sh b/notify.sh new file mode 100755 index 0000000..3e7fa6d --- /dev/null +++ b/notify.sh @@ -0,0 +1,7 @@ +API_HOST="https://api.ssh.surf" +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') -f /root/container-expire-notifs/notify.sh