From fd153f4f766e7537fb3cd2fbb835ddf5dd2a6a21 Mon Sep 17 00:00:00 2001 From: Augustin Trancart Date: Mon, 16 Dec 2019 11:11:02 +0100 Subject: [PATCH] Add admin creation --- manifest.json | 9 +++++++++ scripts/install | 22 ++++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index 8d664fe..8006ba5 100644 --- a/manifest.json +++ b/manifest.json @@ -60,6 +60,15 @@ "fr": "Choisissez l'administrateur de diaspora* (doit être un utilisateur YunoHost)" }, "example": "johndoe" + }, + { + "name": "admin_password", + "type": "password", + "ask": { + "en": "Admin password. Must contain at least 10 characters, one lowercase letter, one uppercase letter, one number, and one symbol (e.g. '~!@#$%^&*()').", + "fr": "Mot de passe pour l’administrateur. Doit contenir au moins 10 caractères, une majuscule, une minuscule, un chiffre, et une ponctuation (ex. '~!@#$%^&*()')." + }, + "optional": false } ] } diff --git a/scripts/install b/scripts/install index df83ab3..10acc18 100755 --- a/scripts/install +++ b/scripts/install @@ -1,12 +1,13 @@ #!/bin/bash # TODO -# - check logrotate # - which service to register to ynuhosto? diaspora.target only ? All of them ? # - backup / restore # - changeurl ? Is that possible ? or even a good idea ? # - make an admin automatically -# - integration with ssowat? Or not? +# - integration with ssowat? Or not? How exactly? +# - a setting to enable / disable registration +# - say something about the registration to https://the-federation.info/ #================================================= # GENERIC START @@ -32,6 +33,7 @@ domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC admin=$YNH_APP_ARG_ADMIN +admin_password=$YNH_APP_ARG_ADMIN_PASSWORD admin_email=$(ynh_user_get_info --username=$admin --key=mail) @@ -234,3 +236,19 @@ fi #================================================= ynh_script_progression --message="Reload nginx..." --time --weight=1 systemctl reload nginx + +#================================================= +# CREATE AN ADMIN +#================================================= +ynh_script_progression --message="Create admin..." --time --weight=1 +pushd $final_path/diaspora +sudo -u diaspora /bin/bash --login << EOF + RAILS_ENV=production bundle exec rails console << END + user = User.build({username: '$admin', email: '$admin_email', password: '$admin_password', password_confirmation: '$admin_password' }) + user.seed_aspects + user.save + Role.add_admin user.person + END +EOF +popd +