mirror of
https://github.com/nextcloud/all-in-one.git
synced 2025-01-01 11:32:27 +08:00
de137f70ae
Signed-off-by: Simon L <szaimen@e.mail.de>
27 lines
No EOL
671 B
Bash
27 lines
No EOL
671 B
Bash
#!/bin/bash
|
|
|
|
if [[ "$EUID" = 0 ]]; then
|
|
COMMAND=(sudo -E -u www-data php /var/www/html/occ)
|
|
else
|
|
COMMAND=(php /var/www/html/occ)
|
|
fi
|
|
|
|
SUBJECT="$1"
|
|
MESSAGE="$2"
|
|
|
|
if [ "$("${COMMAND[@]}" config:app:get notifications enabled)" = "no" ]; then
|
|
echo "Cannot send notification as notification app is not enabled."
|
|
exit 1
|
|
fi
|
|
|
|
echo "Posting notifications to all users..."
|
|
NC_USERS=$("${COMMAND[@]}" user:list | sed 's|^ - ||g' | sed 's|:.*||')
|
|
mapfile -t NC_USERS <<< "$NC_USERS"
|
|
for user in "${NC_USERS[@]}"
|
|
do
|
|
echo "Posting '$SUBJECT' to: $user"
|
|
"${COMMAND[@]}" notification:generate "$user" "$NC_DOMAIN: $SUBJECT" -l "$MESSAGE"
|
|
done
|
|
|
|
echo "Done!"
|
|
exit 0 |