29 lines
927 B
Bash
Executable File
29 lines
927 B
Bash
Executable File
#!/bin/bash
|
|
|
|
API_HOST="https://api.ssh.surf"
|
|
API_KEY="$1"
|
|
|
|
[ -z $API_KEY ] && echo "You need to provide your api key fot this thing to work.
|
|
It is strongly advised enabling privacy mode (\`/privacy\`) for the time of execution" && exit 1
|
|
|
|
hello=$(curl -w %{http_code} -sH "x-ssh-auth: $API_KEY" $API_HOST/hello -o /dev/null)
|
|
|
|
if [[ hello -ne 200 ]]; then
|
|
echo "token not valid, exiting"
|
|
exit 1
|
|
fi
|
|
|
|
echo $API_KEY > /var/tools/container-expire-notifs/.api-key
|
|
|
|
[ ! which at ] && sudo apt install at
|
|
|
|
date=$(curl -sH "x-ssh-auth: $API_KEY" $API_HOST/time | grep -o '"expireDate":"[^"]*' | grep -o '[^"]*$')
|
|
|
|
if ! grep -q "atd" /start.sh; then sed -i -e 's/#s2lmain/atd/g' /start.sh; fi
|
|
atd
|
|
|
|
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"
|