__nextcloud_user: new parameters to prevent changes to the user
This adds new parameters `--only-setup` and `--keep-*` to prevent certain parameters to be changed in Nextcloud. This will not apply to the setup.
This commit is contained in:
parent
635f03f527
commit
82283d0b1c
3 changed files with 125 additions and 58 deletions
|
@ -52,7 +52,7 @@ SHELL
|
|||
fi
|
||||
|
||||
# save that use user will be created and no further steps are required
|
||||
occ_created="yes"
|
||||
ignore_config="yes"
|
||||
}
|
||||
|
||||
# Checks if the key-value exists on the remote side. Only matches first-level
|
||||
|
@ -136,10 +136,16 @@ if [ "$state_is" != "$state_should" ]; then
|
|||
esac
|
||||
fi
|
||||
|
||||
# Check if the user should not be modified further from the initial setup.
|
||||
if [ -f "$__object/parameter/only-setup" ]; then
|
||||
ignore_config="yes"
|
||||
fi
|
||||
|
||||
|
||||
# Check if some user configuration should be changed
|
||||
# do not run this code if the user will be created in the previous code
|
||||
if [ "$state_should" != "absent" ] && [ "$occ_created" != "yes" ]; then
|
||||
if [ "$state_should" != "absent" ] && [ "$ignore_config" != "yes" ]; then
|
||||
if ! [ -f "$__object/parameter/keep-displayname" ]; then
|
||||
# Check if the display name is correct if someone is set
|
||||
if [ -f "$__object/parameter/displayname" ]; then
|
||||
displayname="$(cat "$__object/parameter/displayname")"
|
||||
|
@ -149,12 +155,16 @@ su -s /bin/sh -l "$www_user" -- -e <<'SU'
|
|||
cd '$cloud'
|
||||
php -r 'define("OC_CONSOLE",1); require_once(__DIR__."/lib/base.php");
|
||||
\\OC::\$server->getUserSession()->getManager()->get("$user")->setDisplayName("$displayname")
|
||||
or die("Couldn'\''t modify $user display name! Maybe unsupported or already set ..".PHP_EOL);'
|
||||
or print("Couldn'\''t modify $user display name! Maybe unsupported or already set ..".PHP_EOL)
|
||||
and die(1);'
|
||||
SU
|
||||
SHELL
|
||||
fi
|
||||
fi
|
||||
# the display name can not be unset
|
||||
fi
|
||||
|
||||
if ! [ -f "$__object/paramter/keep-email" ]; then
|
||||
# Check if the email address is correct
|
||||
if [ -f "$__object/parameter/email" ]; then
|
||||
email="$(cat "$__object/parameter/email")"
|
||||
|
@ -167,7 +177,9 @@ SHELL
|
|||
occ user:setting --delete -- "'$user'" settings email
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! [ -f "$__object/parameter/keep-password" ]; then
|
||||
# Check state of the password
|
||||
# explorer handles missing passwords already
|
||||
if [ "$(cat "$__object/explorer/password")" = "mismatched" ]; then
|
||||
|
@ -179,8 +191,10 @@ php occ --no-interaction --no-ansi user:resetpassword --password-from-env -- '$u
|
|||
SU
|
||||
SHELL
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if ! [ -f "$__object/parameter/keep-groups" ]; then
|
||||
# Handle the user groups
|
||||
# extract all groups set by remote
|
||||
mkdir -p "$__object/files"
|
||||
|
@ -216,4 +230,5 @@ SHELL
|
|||
occ group:adduser "'$GROUP'" "'$user'"
|
||||
done < "$__object/files/group.add"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
|
|
@ -9,6 +9,10 @@ cdist-type__nextcloud_user - Setup a Nextcloud user
|
|||
DESCRIPTION
|
||||
-----------
|
||||
It manages a single Nextcloud user given by the object id or parameter `--user`.
|
||||
This type can create and manage most properties of the Nextcloud user. If you
|
||||
only want to setup the user, but want that the user will take full control over
|
||||
all settings (so cdist will not touch the user anymore), use the parameter
|
||||
`--only-setup` or `--keep-*` for special parameters.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
|
@ -44,13 +48,21 @@ www-user
|
|||
webserver and cli execution. As default, `www-data` will be used.
|
||||
|
||||
displayname
|
||||
The display name the user should have.
|
||||
The display name the user should have. As the display name can not be unset
|
||||
or set to empty, this type will ignore the display name if this parameter
|
||||
is not set. Setting the parameter to an empty string leads to an error from
|
||||
the Nextcloud side.
|
||||
|
||||
email
|
||||
The email address of the Nextcloud user.
|
||||
The email address of the Nextcloud user. Will be unset if no parameter
|
||||
given.
|
||||
|
||||
password
|
||||
The password of the Nextcloud user.
|
||||
The password of the Nextcloud user. If the password not match, the new
|
||||
password will be set to the user. If no password is given, it will not
|
||||
touch the current password. **A password is required for the user setup!**
|
||||
If you do not want to modify the user password, set a password via this
|
||||
parameter and set the parameter `--keep-password`.
|
||||
|
||||
quota
|
||||
TBA.
|
||||
|
@ -60,6 +72,40 @@ group
|
|||
user will be removed from every group he is in.
|
||||
|
||||
|
||||
BOOLEAN PARAMETERS
|
||||
------------------
|
||||
only-setup
|
||||
Only provisioning the user if he does not exist. Do not touch the user if
|
||||
he already exists (except to enforce the given state).
|
||||
|
||||
keep-displayname
|
||||
Do not touch the display name of the user if he is already set up. This
|
||||
will avoid to delete the user-set value because it does not match with the
|
||||
predefined state. If the parameter `--displayname` is set despite of this
|
||||
parameter, it will be used in the user setup if he does not already exist.
|
||||
|
||||
keep-email
|
||||
Do not touch the email attributes of the user if he is already set up. This
|
||||
will avoid to delete the user-set value because it does not match with the
|
||||
predefined state. If the parameter `--email` is set despite of this
|
||||
parameter, it will be used in the user setup if he does not already exist.
|
||||
|
||||
keep-password
|
||||
Do not touch the password if the user is already set up. This will avoid to
|
||||
delete user-set passwords because they do not match with the predefined
|
||||
state. If the parameter `--password` is set despite of this parameter, it
|
||||
will be used in the user setup if he does not already exists.
|
||||
|
||||
keep-quota
|
||||
TBA.
|
||||
|
||||
keep-groups
|
||||
Do not touch the user groups if the user is already set up. This will avoid
|
||||
to delete group assosiactions not defined via cdist. If the parameter
|
||||
`--group` is set despite of this parameter, it will be used in the user
|
||||
setup if he does not already exists.
|
||||
|
||||
|
||||
MESSAGES
|
||||
--------
|
||||
created
|
||||
|
|
6
type/__nextcloud_user/parameter/boolean
Normal file
6
type/__nextcloud_user/parameter/boolean
Normal file
|
@ -0,0 +1,6 @@
|
|||
only-setup
|
||||
keep-displayname
|
||||
keep-email
|
||||
keep-password
|
||||
keep-quota
|
||||
keep-groups
|
Loading…
Reference in a new issue