__nextcloud_user: use occ group: commands

Instead of the self-tinkered php code, the correct occ command is used
now.
This commit is contained in:
matze 2020-10-30 20:08:32 +01:00
parent 1e1df1016d
commit 635f03f527

View file

@ -206,34 +206,14 @@ SHELL
# Remove all groups not exist anymore # Remove all groups not exist anymore
if [ -s "$__object/files/group.del" ]; then if [ -s "$__object/files/group.del" ]; then
while read -r GROUP; do while read -r GROUP; do
cat <<SHELL occ group:removeuser "'$GROUP'" "'$user'"
su -s /bin/sh -l "$www_user" -- -e <<'SU'
cd '$cloud'
php -r 'define("OC_CONSOLE",1); require_once(__DIR__."/lib/base.php");
\$group = \\OC::\$server->getGroupManager()->get("$GROUP");
\$user = \\OC::\$server->getUserSession()->getManager()->get("$user");
if (\$group === NULL || \$user === NULL)
die("Can'\''t delete $user from group $GROUP! User or group doesn'\''t exist in nextcloud!".PHP_EOL);
\$group->removeUser(\$user);'
SU
SHELL
done < "$__object/files/group.del" done < "$__object/files/group.del"
fi fi
# Add all existing groups # Add all existing groups
if [ -s "$__object/files/group.add" ]; then if [ -s "$__object/files/group.add" ]; then
while read -r GROUP; do while read -r GROUP; do
cat <<SHELL occ group:adduser "'$GROUP'" "'$user'"
su -s /bin/sh -l "$www_user" -- -e <<'SU'
cd '$cloud'
php -r 'define("OC_CONSOLE",1); require_once(__DIR__."/lib/base.php");
\$group = \\OC::\$server->getGroupManager()->get("$GROUP");
\$user = \\OC::\$server->getUserSession()->getManager()->get("$user");
if (\$group === NULL || \$user === NULL)
die("Can'\''t delete $user from group $GROUP! User or group doesn'\''t exist in nextcloud!".PHP_EOL);
\$group->addUser(\$user);'
SU
SHELL
done < "$__object/files/group.add" done < "$__object/files/group.add"
fi fi
fi fi