various
parent
06d6a7c077
commit
62e5a41bd0
|
@ -178,6 +178,12 @@ function trigger_notify() {
|
||||||
--level "$level" \
|
--level "$level" \
|
||||||
--message "See attached log for details" \
|
--message "See attached log for details" \
|
||||||
--title "$title"
|
--title "$title"
|
||||||
|
elif [[ "$log_path" == "" ]]; then
|
||||||
|
"$notify_prog" \
|
||||||
|
--invoked-by "$(basename $me_filename)" \
|
||||||
|
--level "$level" \
|
||||||
|
--message="$message" \
|
||||||
|
--title="$title"
|
||||||
else
|
else
|
||||||
"$notify_prog" \
|
"$notify_prog" \
|
||||||
--file "$log_path" \
|
--file "$log_path" \
|
||||||
|
@ -360,6 +366,7 @@ test_file "$restic_repo_passwd_file"
|
||||||
if [[ -z "$1" || -f "$1" ]]; then
|
if [[ -z "$1" || -f "$1" ]]; then
|
||||||
if [[ -z "$1" ]]; then
|
if [[ -z "$1" ]]; then
|
||||||
say info "Running backup scripts..."
|
say info "Running backup scripts..."
|
||||||
|
trigger_notify "info" "Backup started" "Running all scripts from '$backup_scripts_dir'"
|
||||||
|
|
||||||
if ! [[ "$(ls -A $backup_scripts_dir)" ]]; then
|
if ! [[ "$(ls -A $backup_scripts_dir)" ]]; then
|
||||||
die "No scripts found in '$backup_scripts_dir'"
|
die "No scripts found in '$backup_scripts_dir'"
|
||||||
|
|
|
@ -10,6 +10,26 @@ _PLUG_ARGS=(
|
||||||
"invoked-by;i;;string"
|
"invoked-by;i;;string"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
function get_host_emoji() {
|
||||||
|
hostname="$1"
|
||||||
|
hostname_length="${#hostname}"
|
||||||
|
|
||||||
|
if [[ "$hostname" =~ ([a-z]{2}[0-9]{2,3}) ]]; then
|
||||||
|
case "$hostname" in
|
||||||
|
"de") echo "🇩🇪" ;;
|
||||||
|
"fi") echo "🇫🇮" ;;
|
||||||
|
"fr") echo "🇫🇷" ;;
|
||||||
|
"gb") echo "🇬🇧" ;;
|
||||||
|
"nl") echo "🇳🇱" ;;
|
||||||
|
*) echo "❔" ;;
|
||||||
|
esac
|
||||||
|
elif [[ "$hostname" =~ ([a-z]{3}[0-9]{3}) ]]; then
|
||||||
|
echo "☁️"
|
||||||
|
else
|
||||||
|
echo "🖥️"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function get_level_emoji() {
|
function get_level_emoji() {
|
||||||
case "$1" in
|
case "$1" in
|
||||||
"critical"|"error") echo "⛔" ;;
|
"critical"|"error") echo "⛔" ;;
|
||||||
|
@ -50,17 +70,19 @@ function main() {
|
||||||
token="$(cat "$token_path")"
|
token="$(cat "$token_path")"
|
||||||
|
|
||||||
hostname="$(hostname -s)"
|
hostname="$(hostname -s)"
|
||||||
|
host_emoji="$(get_host_emoji $hostname)"
|
||||||
invoked_by="$_invoked_by"
|
invoked_by="$_invoked_by"
|
||||||
level_emoji="$(get_level_emoji "$_level")"
|
level_emoji="$(get_level_emoji "$_level")"
|
||||||
|
priority="$(get_level_priority "$_level")"
|
||||||
topic="$(get_topic "$_invoked_by")"
|
topic="$(get_topic "$_invoked_by")"
|
||||||
|
|
||||||
curl_command="curl"
|
curl_command="curl"
|
||||||
|
|
||||||
curl_command+=" -H \"Authorization: Bearer $token\""
|
curl_command+=" -H \"Authorization: Bearer $token\""
|
||||||
curl_command+=" -H \"Markdown: yes\""
|
curl_command+=" -H \"Markdown: yes\""
|
||||||
curl_command+=" -H \"Priority: $(get_level_priority "$_level")\""
|
curl_command+=" -H \"Priority: $priority\""
|
||||||
curl_command+=" -H \"Tags: $hostname,$invoked_by\""
|
curl_command+=" -H \"Tags: $hostname,$invoked_by\""
|
||||||
curl_command+=" -H \"Title: $level_emoji [$hostname] $_title\""
|
curl_command+=" -H \"Title: $host_emoji $hostname | $level_emoji $_title\""
|
||||||
|
|
||||||
if [[ "$_message" != "true" ]]; then
|
if [[ "$_message" != "true" ]]; then
|
||||||
curl_command+=" -H \"Message: $_message\""
|
curl_command+=" -H \"Message: $_message\""
|
||||||
|
|
Loading…
Reference in New Issue