From 15e19ce6c93671b0c21fc8e208873515a5be951b Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Fri, 16 Feb 2018 06:25:18 +0000 Subject: [PATCH] Create first user and team from the app install --- check_process | 8 +++++--- manifest.json | 36 ++++++++++++++++++++++++++++++++++++ scripts/install | 21 +++++++++++++++++++++ 3 files changed, 62 insertions(+), 3 deletions(-) diff --git a/check_process b/check_process index 2beeea8..43764ff 100644 --- a/check_process +++ b/check_process @@ -2,10 +2,12 @@ ; Manifest domain="ynhtests.local" (DOMAIN) path="" (PATH) - user="admin" (USER) - language="fr" + admin_email="john@gmail.com" + admin_password="mattermost_password" + admin_locale="fr" + team_display_name="Mon équipe" is_public=1 (PUBLIC|public=1|private=0) - password="alpine" + analytics=0 ; Checks pkg_linter=1 setup_root=1 diff --git a/manifest.json b/manifest.json index 863002e..d4a2ee7 100644 --- a/manifest.json +++ b/manifest.json @@ -40,6 +40,42 @@ }, "default": true }, + { + "name": "admin_email", + "ask": { + "en": "Login email for the chat admin", + "fr": "Adresse email de login pour l’administrateur du chat" + }, + "example": "john@gmail.com", + "optional": false + }, + { + "name": "admin_password", + "type": "password", + "ask": { + "en": "Password for the chat admin", + "fr": "Mot de passe pour l’administrateur du chat" + }, + "optional": false + }, + { + "name": "admin_locale", + "ask": { + "en": "Choose the language of the chat for the admin", + "fr": "Choissisez la langue utilisée pour l'administrateur" + }, + "choices": ["en", "fr"], + "default": "en" + }, + { + "name": "team_display_name", + "ask": { + "en": "Choose a Team name", + "fr": "Choisissez le nom de l’équipe" + }, + "example": "Super Groupe", + "optional": false + }, { "name": "analytics", "type": "boolean", diff --git a/scripts/install b/scripts/install index 613e095..e1f29bf 100644 --- a/scripts/install +++ b/scripts/install @@ -23,6 +23,10 @@ ynh_abort_if_errors app=$YNH_APP_INSTANCE_NAME domain=$YNH_APP_ARG_DOMAIN is_public=$YNH_APP_ARG_IS_PUBLIC +admin_email=$YNH_APP_ARG_ADMIN_EMAIL +admin_password=$YNH_APP_ARG_ADMIN_PASSWORD +admin_locale=$YNH_APP_ARG_ADMIN_LOCALE +team_display_name=$YNH_APP_ARG_TEAM_DISPLAY_NAME analytics=$YNH_APP_ARG_ANALYTICS path_url="/" @@ -194,3 +198,20 @@ sudo systemctl reload nginx #================================================= sudo systemctl start "$app" + +#================================================= +# CREATE ADMIN AND FIRST TEAM +#================================================= + +admin_username=$(cut -d @ -f 1 <<< "$admin_email") +team_name=$(echo "$team_display_name" | iconv -f utf8 -t ascii//TRANSLIT//IGNORE | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z) + +cd "$final_path/bin" +sudo ./platform user create --username "$admin_username" --email "$admin_email" --password "$admin_password" --locale "$admin_locale" --system_admin +sudo ./platform user verify "$admin_username" +sudo ./platform team create --name "$team_name" --display_name "$team_display_name" --email "$admin_email" +sudo ./platform team add "$team_name" "$admin_username" + +ynh_app_setting_set "$app" admin_email "$admin_email" +ynh_app_setting_set "$app" admin_locale "$admin_locale" +ynh_app_setting_set "$app" team_name "$team_name"