From 56e8ec388bc4ae931753e83342534e0bad3b1e00 Mon Sep 17 00:00:00 2001 From: thomasabishop Date: Wed, 29 Oct 2025 13:37:41 +0000 Subject: [PATCH] chore: tidy up --- .../rocketchat_notifier.sh | 0 slack_notifier.sh | 87 ------------------- vps_backups/copy_vps_backup_to_local.sh | 2 +- 3 files changed, 1 insertion(+), 88 deletions(-) rename rocketchat_notifier.sh => old/rocketchat_notifier.sh (100%) delete mode 100755 slack_notifier.sh diff --git a/rocketchat_notifier.sh b/old/rocketchat_notifier.sh similarity index 100% rename from rocketchat_notifier.sh rename to old/rocketchat_notifier.sh diff --git a/slack_notifier.sh b/slack_notifier.sh deleted file mode 100755 index 654563b..0000000 --- a/slack_notifier.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/bash - -# Send error and success notifications to Slack channels - -# Env vars: -# --- Webhook URLs for given channel, eg $SLACK_WEBHOOK_TEST, $SLACK_WEBHOOK_EOLAS -# --- sourced from `.env` file in Zsh path - -# Parameters: -# --- $1 = Slack channel, -# --- $2 = type 'error' | 'success' -# --- $3 = Message -# --- $4 = (Opt) Error details -# --- $5 = (Opt) Error source - -# Usage: -# --- ./slack_notifier.sh test 'SUCCESS: ...' -# --- ./slack_notifier.sh test 'ERROR: ... ' 'Error details' 'source' - -declare -A CHANNEL_TO_WEBHOOK -CHANNEL_TO_WEBHOOK["test"]=$SLACK_WEBHOOK_TEST -CHANNEL_TO_WEBHOOK["backups"]=$SLACK_WEBHOOK_BACKUPS -CHANNEL_TO_WEBHOOK["eolas"]=$SLACK_WEBHOOK_EOLAS -CHANNEL_TO_WEBHOOK["website"]=$SLACK_WEBHOOK_SYSTEMS_OBSCURE -CHANNEL_TO_WEBHOOK["time-tracking"]=$SLACK_WEBHOOK_TIME_TRACKING - -WEBHOOK=${CHANNEL_TO_WEBHOOK[$1]} - -ERROR_BLOCKS=$( - jq -n \ - --arg channel "$1" \ - --arg message "$3" \ - --arg details "$4" \ - --arg source "$5" \ - '{ - channel: $channel, - blocks: ([ - { - type: "section", - text: { - type: "plain_text", - text: "🔴 \($message)" - } - }, - { - type: "section", - text: { - type: "mrkdwn", - text: "```\n\($details)\n```" - } - }, - { - "type": "context", - "elements": [ - { - "type": "plain_text", - text: $source - } - ] - } - ]) - }' -) - -# Initialise sound playback - -# mpv --volume=0 --start=0 --length=0.1 "${HOME}/dotfiles/sounds/star-trek-computer-success.mp3" \ -# >/dev/null 2>&1 -# sleep 1 - -# Process notification -if [ "$2" != "error" ]; then - curl -X POST \ - -H 'Content-type: application/json' \ - --data '{"text":"🟢 '"$3"'"}' \ - "$WEBHOOK" - # mpv --volume=100 "${HOME}/dotfiles/sounds/star-trek-computer-success.mp3" \ - >/dev/null 2>&1 - -else - curl -X POST \ - -H 'Content-type: application/json' \ - --json "$ERROR_BLOCKS" \ - "$WEBHOOK" - # mpv --volume=100 "${HOME}/dotfiles/sounds/star-trek-computer-error.mp3" \ - >/dev/null 2>&1 -fi diff --git a/vps_backups/copy_vps_backup_to_local.sh b/vps_backups/copy_vps_backup_to_local.sh index 46789ba..ea9178a 100755 --- a/vps_backups/copy_vps_backup_to_local.sh +++ b/vps_backups/copy_vps_backup_to_local.sh @@ -6,7 +6,7 @@ # --- $2 = Database location on VPS, e.g. "thomas@systemsobscure.net:/home/thomas/backups/forgejo/*.sql.gz" # --- $3 = Backup location path on VPS, e.g. "/vps_backups/mysql/forgejo/" -source "$HOME/.env" +source /home/thomas/.env LOCAL_MOUNTPOINT="/media/my-passport" RCHAT_NOTIFIER="${HOME}/repos/utilities/rocketchat_notifier.sh"