From b621d35f69ce565dd5ac09fe348c8f60b43e8a80 Mon Sep 17 00:00:00 2001 From: Felix <122696847+felix-schott@users.noreply.github.com> Date: Thu, 12 Dec 2024 11:29:52 +0000 Subject: [PATCH] close #105, #102 (#109) * close #105, #102 * changelog --- CHANGELOG.md | 11 +++++++++++ deploy/install.sh | 9 +++------ deploy/migrations-alert.sh | 23 ++++++++++++++++++----- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a12338b..d422a6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Calendar Versioning](https://calver.org/) (`YYYY.MM.MICRO-TAG`). +## [v2024.12.1] - 2024-12-12 + +### Added + +- Added field in `AddSessionPopup` for submission notes and optional email address plus backend support for that feature, implemented as comments in migration scripts (PR [#107](https://github.com/felix-schott/jamsessions/pull/107)) + +### Fixed + +- Fixed bug in geocoding module that occured when an address 2nd line was supplied (PR [#106](https://github.com/felix-schott/jamsessions/pull/106)) +- Some fixes related to the `migrations-alert.sh` script (PR [#109](https://github.com/felix-schott/jamsessions/pull/109)) + ## [v2024.12.0] - 2024-12-02 ### Changed diff --git a/deploy/install.sh b/deploy/install.sh index 44b2603..9a70433 100644 --- a/deploy/install.sh +++ b/deploy/install.sh @@ -89,11 +89,8 @@ will write little bash scripts to $directory/migrations that make use the dbcli Review the script contents and execute run-migrations.sh to apply all changes. EOF -crontab -l | grep migrations-alert.sh -q &> /dev/null && { - echo "Alerting cron job already installed" -} || { - echo "Installing alerting cron job"; - (crontab -l ; echo "0 */2 * * * bash $directory/migrations-alert.sh") | crontab - -} +echo "Installing alerting cron job" +set +eo pipefail +(crontab -l; echo "0 */2 * * * cd $directory && bash $directory/migrations-alert.sh $directory") | sort - | uniq - | crontab -; echo "Finished installation process - please consult the generated README file for further instructions." \ No newline at end of file diff --git a/deploy/migrations-alert.sh b/deploy/migrations-alert.sh index 001684f..25bc4a9 100644 --- a/deploy/migrations-alert.sh +++ b/deploy/migrations-alert.sh @@ -2,18 +2,31 @@ set -eo pipefail +# load .env file if it exists +[[ ! -f .env ]] || set -a && source .env && set +a + [[ $1 == "" ]] && echo "Please provide the target directory of the installation as a positional argument." 1>&2 && exit 1; -directory=$1/migrations +directory=$1 [[ $TELEGRAM_TOKEN == "" ]] && echo "Please provide the environment variable TELEGRAM_TOKEN." 1>&2 && exit 1; [[ $TELEGRAM_CHAT_ID == "" ]] && echo "Please provide the environment variable TELEGRAM_CHAT_ID." 1>&2 && exit 1; send_alert () { - curl -X POST https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendMessage -d '{"chat_id":'${TELEGRAM_CHAT_ID}',"text":"PENDING MIGRATIONS"}' -H 'Content-Type: application/json' + type=$1 + echo "Sending $type alert" + curl -X POST https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendMessage -d '{"chat_id":'${TELEGRAM_CHAT_ID}',"text":"PENDING '$type'"}' -H 'Content-Type: application/json' } -if [[ -d $directory ]]; then - ls $directory/*.sh &> /dev/null && send_alert &> /dev/null +echo "Inspecting $directory/migrations directory" +if [[ -d "$directory/migrations" ]]; then + ls $directory/migrations/*.sh &> /dev/null && send_alert "MIGRATIONS" &> /dev/null +else + echo "Directory $directory/migrations does not exist" 1>&2 && exit 1 +fi + +echo "Inspecting $directory/migrations/suggestions directory" +if [[ -d "$directory/migrations/suggestions" ]]; then + ls $directory/migrations/suggestions/*.sh &> /dev/null && send_alert "SUGGESTIONS" &> /dev/null else - echo "Directory $directory does not exist" 1>&2 && exit 1 + echo "Directory $directory/migrations/suggestions does not exist" 1>&2 && exit 1 fi \ No newline at end of file