commit 7aa98e51c71c648987fd0a4d94b98d71c216f283
parent 94755a5a90cb10750b238d1c7c36e3af89a96e37
Author: oscarbenedito <oscar@obenedito.org>
Date:   Tue,  3 Mar 2020 22:55:57 +0100

Tokens in different files

Diffstat:
Matenea-updates-notifications/atenea-updates-notifications.py | 4++--
Ascripts/.gitignore | 2++
Mscripts/deploy_website.sh | 8++++----
Mscripts/login-notify.sh | 7++++---
4 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/atenea-updates-notifications/atenea-updates-notifications.py b/atenea-updates-notifications/atenea-updates-notifications.py @@ -30,10 +30,10 @@ COURSE_IDS = { } -with open('api_token.txt', 'r') as f: +with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'api_token.txt'), 'r') as f: API_TOKEN = f.read().strip() -with open('notification_token.txt', 'r') as f: +with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'notification_token.txt'), 'r') as f: NOTIFICATION_TOKEN = f.read().strip() diff --git a/scripts/.gitignore b/scripts/.gitignore @@ -0,0 +1,2 @@ +website_api_token.txt +login_api_token.txt diff --git a/scripts/deploy_website.sh b/scripts/deploy_website.sh @@ -19,18 +19,18 @@ # Script to deploy a website built with Hugo. HUGO_PATH="/srv/oscarbenedito.com" +GOTIFY_DOMAIN="gotify.oscarbenedito.com" git -C $HUGO_PATH pull rm -rf $HUGO_PATH/public rm -rf $HUGO_PATH/resources -hugo -s $HUGO_PATH --minify +hugo -s $HUGO_PATH --gc -DOMAIN=gotify.oscarbenedito.com -API_TOKEN=<redacted> +API_TOKEN="$(cat "$(dirname "$(realpath "$0")")/website_api_token.txt")" TITLE="Web update triggered" MESSAGE="Git hooks triggered an update of the website." -curl -X POST "https://$DOMAIN/message?token=$API_TOKEN" \ +curl -X POST "https://$GOTIFY_DOMAIN/message?token=$API_TOKEN" \ -F "title=$TITLE" \ -F "message=$MESSAGE" \ -F "priority=5" \ diff --git a/scripts/login-notify.sh b/scripts/login-notify.sh @@ -18,15 +18,16 @@ # Script that notifies Gotify when someone logs in through SSH to a computer/server. -DOMAIN=gotify.oscarbenedito.com -API_TOKEN=<redacted> +GOTIFY_DOMAIN="gotify.oscarbenedito.com" + +API_TOKEN="$(cat "$(dirname "$(realpath "$0")")/login_api_token.txt")" if [ "$PAM_TYPE" != "close_session" ]; then TITLE="SSH login: ${PAM_USER}@$(hostname)" MESSAGE="IP: ${PAM_RHOST} Date: $(TZ='Europe/Madrid' date)" - curl -X POST "https://$DOMAIN/message?token=$API_TOKEN" \ + curl -X POST "https://$GOTIFY_DOMAIN/message?token=$API_TOKEN" \ -F "title=$TITLE" \ -F "message=$MESSAGE" \ -F "priority=5" \