diff --git a/lib.sh b/lib.sh index 44106a34..36d894a1 100644 --- a/lib.sh +++ b/lib.sh @@ -1080,6 +1080,32 @@ case "${1}" in esac } +# Example: +# notify_user_gui \ +# "Subject" \ +# "Message" +# +# occ_command notification:generate -l "$2" "$admin" "$1" +notify_user_gui() { +USER=$(occ_command user:list | awk '{print $2}' | cut -d ":" -f1;) +print_text_in_color "$ICyan" "Looping through users, this might take a while..." +for user in $USER +do + if occ_command user:info "$user" | grep -q "\- admin"; + then + print_text_in_color "$ICyan" "Found: $user" + local admin_users+="$user " + fi +done + +print_text_in_color "$ICyan" "Posting notification to users that are admins:" +for admin in ${admin_users[*]} +do + occ_command notification:generate -l "$2" "$admin" "$1" + print_text_in_color "$IGreen" "$admin" +done +} + ## bash colors # Reset Color_Off='\e[0m' # Text Reset diff --git a/nextcloud-startup-script.sh b/nextcloud-startup-script.sh index 716bbf40..6908d4f1 100644 --- a/nextcloud-startup-script.sh +++ b/nextcloud-startup-script.sh @@ -537,10 +537,13 @@ then fi clear -# Set notifications for admin -NCADMIN=$(occ_command user:list | awk '{print $3}') -occ_command notification:generate -l "Please remember to setup SMTP to be able to send shared links, user notifications and more via email. Please go here and start setting it up: https://your-nextcloud/settings/admin." "$NCADMIN" "Please setup SMTP" -occ_command notification:generate -l "If you need support, please visit the shop: https://shop.hanssonit.se" "$NCADMIN" "Do you need support?" +notify_user_gui \ +"Please setup SMTP" \ +"Please remember to setup SMTP to be able to send shared links, user notifications and more via email. Please go here and start setting it up: https://your-nextcloud/settings/admin." + +notify_user_gui \ +"Do you need support?" \ +"If you need support, please visit the shop: https://shop.hanssonit.se, or the forum: https://help.nextcloud.com." # Fixes https://github.com/nextcloud/vm/issues/58 a2dismod status diff --git a/nextcloud_update.sh b/nextcloud_update.sh index bb2ae67c..af04436d 100644 --- a/nextcloud_update.sh +++ b/nextcloud_update.sh @@ -626,7 +626,10 @@ To recover your old apps, please check $BACKUP/apps and copy them to $NCPATH/app Thank you for using T&M Hansson IT's updater!" occ_command status occ_command maintenance:mode --off - echo "NEXTCLOUD UPDATE success-$(date +"%Y%m%d")" >> "$VMLOGS"/update_run.log + print_text_in_color "ICyan" "Sending notification about the successful update to all admins..." + notify_user_gui "Nextcloud is now updated!" \. + "Your Nextcloud is updated to $CURRENTVERSION_after with the update script in the Nextcloud VM." + echo "NEXTCLOUD UPDATE success-$(date +"%Y%m%d")" >> "$VMLOGS"/update.log exit 0 else msg_box "Latest version is: $NCVERSION. Current version is: $CURRENTVERSION_after. @@ -637,6 +640,8 @@ Your files are still backed up at $BACKUP. No worries! Please report this issue to $ISSUES Maintenance mode is kept on." -occ_command status + notify_user_gui "Nextcloud update failed!" \ + "Your Nextcloud update failed, please check the logs at $VMLOGS/update.log" + occ_command status exit 1 fi