Add mirror/mirror_failnotify.sh
This commit is contained in:
61
mirror/mirror_failnotify.sh
Normal file
61
mirror/mirror_failnotify.sh
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Notification Settings for Nfty.sh. Ajust the topic
|
||||||
|
ntfy_topic="TOPIC"
|
||||||
|
ntfy_server="ntfy.sh"
|
||||||
|
|
||||||
|
# Timestamp for notifications
|
||||||
|
now=$(date '+%F_%H%M%S')
|
||||||
|
|
||||||
|
notify() {
|
||||||
|
curl -H "Title: $1" \
|
||||||
|
-H "Priority: $2" \
|
||||||
|
-H "Tags: $3" \
|
||||||
|
-H "Markdown: yes" \
|
||||||
|
-d "$4" \
|
||||||
|
"$ntfy_server/$ntfy_topic"
|
||||||
|
}
|
||||||
|
|
||||||
|
title="$(hostname)"
|
||||||
|
|
||||||
|
mirror() {
|
||||||
|
local cmd="$1"
|
||||||
|
local description="$2"
|
||||||
|
|
||||||
|
# Run the command and capture the output and status
|
||||||
|
if ! output=$($cmd 2>&1); then
|
||||||
|
notify "$title" "high" "mirror" \
|
||||||
|
"$description failed at $now with error: $output"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Command succeeded: $description"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Set environment variables
|
||||||
|
export GNUPGHOME=/mirror/debmirror/mirrorkeyring
|
||||||
|
|
||||||
|
# Variables for debmirror
|
||||||
|
arch=amd64
|
||||||
|
section=main,restricted,universe,multiverse
|
||||||
|
release=noble,noble-security,noble-updates,noble-backports
|
||||||
|
mirror_server=mirror.aarnet.edu.au
|
||||||
|
inPath=/ubuntu
|
||||||
|
proto=http
|
||||||
|
outPath=/mirror/debmirror/amd64
|
||||||
|
|
||||||
|
# Ensure the output directory exists
|
||||||
|
mkdir -p "$outPath"
|
||||||
|
|
||||||
|
# Run debmirror wrapped in `mirror` for notification
|
||||||
|
mirror "debmirror -a $arch \
|
||||||
|
--no-source \
|
||||||
|
--rsync-options --recursive \
|
||||||
|
--rsync-options --partial \
|
||||||
|
-s $section \
|
||||||
|
-h $mirror_server \
|
||||||
|
-d $release \
|
||||||
|
-r $inPath \
|
||||||
|
--progress \
|
||||||
|
--method=$proto \
|
||||||
|
$outPath" "Debmirror synchronization"
|
||||||
Reference in New Issue
Block a user