34 lines
715 B
Bash
34 lines
715 B
Bash
#! /bin/bash
|
|
|
|
if [[ $EUID != 0 ]]; then
|
|
# We're not root... yet!
|
|
sudo forgehook-notify $@
|
|
exit $?
|
|
fi
|
|
|
|
# We only take one argument!
|
|
if [[ $# != 1 ]]; then
|
|
echo "FATAL ERROR: forgehook-notify can't deal with $# argument(s) (BUG)"
|
|
[[ $# != 0 ]] && echo "Found arguments: "$@""
|
|
exit 1
|
|
fi
|
|
|
|
# Ok now we're root
|
|
|
|
r="$1"
|
|
# hexencode URL
|
|
rhex="$(echo -n "$r" | base64)"
|
|
|
|
# Don't loop when nothing matches, plz?
|
|
shopt -s nullglob
|
|
|
|
# Iterate over the hex-encoded URL's subscriptions
|
|
IFS= echo "$(forgehook list "$1")" | while read -r user; do
|
|
#for i in $db/"$rhex".*; do
|
|
# Strip $rhex prefix
|
|
user="$(basename "$user")"
|
|
user="${user#$rhex.}"
|
|
|
|
sudo -u "$user" forgehook-trigger "$1"
|
|
done
|