From 5493d4de221898e17fead6c11a630e9da2963f29 Mon Sep 17 00:00:00 2001 From: southerntofu Date: Tue, 28 Apr 2020 14:20:40 +0200 Subject: [PATCH] forgehook-notify is database-agnostic --- bin/forgehook-notify | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/bin/forgehook-notify b/bin/forgehook-notify index f43d052..830bef0 100644 --- a/bin/forgehook-notify +++ b/bin/forgehook-notify @@ -2,18 +2,10 @@ if [[ $EUID != 0 ]]; then # We're not root... yet! - # Let's not forget to define the db while we have forgehook $USER - # TODO: replace with ~/database - db=$HOME/webhooks sudo forgehook-notify $@ exit $? fi -# If the $db is empty/unset, we have a logic bug somewhere! -if [ -z $db ]; then - echo "FATAL ERROR: Could not find forgehook database (BUG)" -fi - # We only take one argument! if [[ $# != 1 ]]; then echo "FATAL ERROR: forgehook-notify can't deal with $# argument(s) (BUG)" @@ -31,9 +23,10 @@ rhex="$(echo -n "$r" | base64)" shopt -s nullglob # Iterate over the hex-encoded URL's subscriptions -for i in $db/"$rhex".*; do +IFS= echo "$(forgehook list "$1")" | while read -r user; do +#for i in $db/"$rhex".*; do # Strip $rhex prefix - user="$(basename "$i")" + user="$(basename "$user")" user="${user#$rhex.}" sudo -u "$user" forgehook-trigger "$1"