Cleanup Nextcloud users #4

Open
opened 2025-05-17 10:32:16 +02:00 by phil · 0 comments
Owner

This is the first version of the script to remove Nextcloud users:

#!/bin/bash

#
# This script searches for non-existing LDAP in the Nextcloud
# database and deletes them.
#

set -eu

OCC_USER=nextcloud
OCC_DIR=/data/nextcloud/coop.systemausfall.org

# Search for non-existing users
list_users=$(sudo -u "$OCC_USER" php "$OCC_DIR"/occ ldap:show-remnants --json | jq -r '.[].ocName')

while IFS= read -r user; do
    echo "Delete user: $user"
    sudo -u "$OCC_USER" php "$OCC_DIR"/occ user:delete "$user"
done <<< "$list_users"

Any feedback, @lars ?

This is the first version of the script to remove Nextcloud users: ```SHELL #!/bin/bash # # This script searches for non-existing LDAP in the Nextcloud # database and deletes them. # set -eu OCC_USER=nextcloud OCC_DIR=/data/nextcloud/coop.systemausfall.org # Search for non-existing users list_users=$(sudo -u "$OCC_USER" php "$OCC_DIR"/occ ldap:show-remnants --json | jq -r '.[].ocName') while IFS= read -r user; do echo "Delete user: $user" sudo -u "$OCC_USER" php "$OCC_DIR"/occ user:delete "$user" done <<< "$list_users" ``` Any feedback, @lars ?
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: systemausfall.org/nixnutz#4
No description provided.