From 1e7ae885b4706a004c4101bdfccd721edaa03009 Mon Sep 17 00:00:00 2001 From: Philipp Heckel Date: Mon, 29 Nov 2021 15:34:29 -0500 Subject: [PATCH] Update examples --- examples/linux-desktop-notifications/notify-desktop.sh | 4 +++- examples/ssh-login-alert/ntfy-ssh-login.sh | 4 +++- server/cache_sqlite.go | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/linux-desktop-notifications/notify-desktop.sh b/examples/linux-desktop-notifications/notify-desktop.sh index bc93128c..2e20fc42 100644 --- a/examples/linux-desktop-notifications/notify-desktop.sh +++ b/examples/linux-desktop-notifications/notify-desktop.sh @@ -2,6 +2,8 @@ # This is an example shell script showing how to consume a ntfy.sh topic using # a simple script. The notify-send command sends any arriving message as a desktop notification. +TOPIC_URL=ntfy.sh/mytopic + while read msg; do [ -n "$msg" ] && notify-send "$msg" -done < <(stdbuf -i0 -o0 curl -s ntfy.sh/mytopic/raw) +done < <(stdbuf -i0 -o0 curl -s $TOPIC_URL/raw) diff --git a/examples/ssh-login-alert/ntfy-ssh-login.sh b/examples/ssh-login-alert/ntfy-ssh-login.sh index 4c92c44b..1c9c1407 100644 --- a/examples/ssh-login-alert/ntfy-ssh-login.sh +++ b/examples/ssh-login-alert/ntfy-ssh-login.sh @@ -2,6 +2,8 @@ # This is a PAM script hook that shows how to notify you when # somebody logs into your server. Place at /usr/local/bin/ntfy-ssh-login.sh (with chmod +x!). +TOPIC_URL=ntfy.sh/alerts + if [ "${PAM_TYPE}" = "open_session" ]; then - echo -en "\u26A0\uFE0F SSH login to $(hostname): ${PAM_USER} from ${PAM_RHOST}" | curl -T- ntfy.sh/alerts + curl -H tags:warning -H prio:high -d "SSH login to $(hostname): ${PAM_USER} from ${PAM_RHOST}" "${TOPIC_URL}" fi diff --git a/server/cache_sqlite.go b/server/cache_sqlite.go index 6ba4bbc9..a6211d3e 100644 --- a/server/cache_sqlite.go +++ b/server/cache_sqlite.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" _ "github.com/mattn/go-sqlite3" // SQLite driver + "log" "strings" "time" ) @@ -210,6 +211,7 @@ func setupNewDB(db *sql.DB) error { } func migrateFrom0To1(db *sql.DB) error { + log.Print("Migrating cache database schema: from 0 to 1") if _, err := db.Exec(migrate0To1AlterMessagesTableQuery); err != nil { return err }