From 66ad858105b1fb13b165456420d9ea8ffa058ec1 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Mon, 8 Jan 2024 19:37:36 +0100 Subject: [PATCH] fix password at user configuration --- doc/POST_INSTALL.md | 8 ++++++++ doc/POST_INSTALL_fr.md | 8 ++++++++ scripts/_common.sh | 6 +++--- scripts/install | 14 ++++++++------ scripts/restore | 6 +++--- scripts/upgrade | 20 +++++++++++--------- 6 files changed, 41 insertions(+), 21 deletions(-) create mode 100644 doc/POST_INSTALL.md create mode 100644 doc/POST_INSTALL_fr.md diff --git a/doc/POST_INSTALL.md b/doc/POST_INSTALL.md new file mode 100644 index 0000000..52a1e54 --- /dev/null +++ b/doc/POST_INSTALL.md @@ -0,0 +1,8 @@ +Æneria is now installed! + +You can access it here: <__PATH__> + +Your login is: `__MAIL__` +Your password is: `__DEFAULT_PASSWORD__` + +Please change this generated default password in the æneria settings. diff --git a/doc/POST_INSTALL_fr.md b/doc/POST_INSTALL_fr.md new file mode 100644 index 0000000..4db000a --- /dev/null +++ b/doc/POST_INSTALL_fr.md @@ -0,0 +1,8 @@ +Æneria est désormais installé ! + +Vous pouvez y accéder à cette adresse : <__PATH__> + +Votre identifiant : `__MAIL__` +Votre mot de passe : `__DEFAULT_PASSWORD__` + +Merci de changer ce mot de passe généré par défaut dans les paramètres de æneria. diff --git a/scripts/_common.sh b/scripts/_common.sh index b867d23..2031809 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -19,8 +19,8 @@ generate_random_minutes_hour () { minutes="$(ynh_string_random --length=1 --filter=0-5)$(ynh_string_random --length=1 --filter=0-9)" hour="$(ynh_string_random --length=1 --filter=0-2)" - ynh_app_setting_set --app=$app --key=minutes --value=$minutes - ynh_app_setting_set --app=$app --key=hour --value=$hour + ynh_app_setting_set --app="$app" --key=minutes --value="$minutes" + ynh_app_setting_set --app="$app" --key=hour --value="$hour" } #================================================= @@ -46,7 +46,7 @@ ynh_smart_mktemp () { # Check if there's enough free space in a directory is_there_enough_space () { local free_space=$(df --output=avail "$1" | sed 1d) - test $free_space -ge $min_size + test "$free_space" -ge $min_size } if is_there_enough_space /tmp; then diff --git a/scripts/install b/scripts/install index 1fa354e..b9b8efc 100644 --- a/scripts/install +++ b/scripts/install @@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers #================================================= deskey=$(ynh_string_random --length=24) -ynh_app_setting_set --app=$app --key=deskey --value=$deskey +ynh_app_setting_set --app="$app" --key=deskey --value="$deskey" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -25,7 +25,7 @@ ynh_script_progression --message="Setting up source files..." --weight=1 ynh_setup_source --dest_dir="$install_dir" chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" +chown -R "$app:www-data" "$install_dir" #================================================= # SYSTEM CONFIGURATION @@ -56,12 +56,14 @@ chmod 600 "$install_dir/.env" ynh_script_progression --message="Installing aeneria..." --weight=1 # Install aeneria -pushd $install_dir - ynh_exec_as $app php$phpversion bin/console aeneria:install "$app" -n +pushd "$install_dir" + ynh_exec_as "$app" "php$phpversion" bin/console aeneria:install "$app" -n # Create admin user mail=$(ynh_user_get_info --username="$admin" --key='mail') - ynh_exec_as $app php$phpversion bin/console aeneria:user:add "$mail" "$(ynh_string_random)" -n - ynh_exec_as $app php$phpversion bin/console aeneria:user:grant "$mail" + default_password="$(ynh_string_random)" + ynh_app_setting_set --app="$app" --key=default_password --value="$default_password" + ynh_exec_as "$app" "php$phpversion" bin/console aeneria:user:add "$mail" "$default_password" -n + ynh_exec_as "$app" "php$phpversion" bin/console aeneria:user:grant "$mail" popd #================================================= diff --git a/scripts/restore b/scripts/restore index 3c6e57d..5357cd5 100644 --- a/scripts/restore +++ b/scripts/restore @@ -18,14 +18,14 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$install_dir" chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" +chown -R "$app:www-data" "$install_dir" #================================================= # RESTORE THE PSQL DATABASE #================================================= ynh_script_progression --message="Restoring the PSQL database..." --weight=1 -ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql +ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql #================================================= # RESTORE SYSTEM CONFIGURATIONS @@ -48,7 +48,7 @@ ynh_restore_file --origin_path="/etc/cron.d/$app" #================================================= ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1 -ynh_systemd_action --service_name=php$phpversion-fpm --action=reload +ynh_systemd_action --service_name="php$phpversion-fpm" --action=reload ynh_systemd_action --service_name=nginx --action=reload #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index bea1232..d702203 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -55,7 +55,7 @@ then fi chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" +chown -R "$app:www-data" "$install_dir" #================================================= # REAPPLY SYSTEM CONFIGURATIONS @@ -90,21 +90,23 @@ chmod 600 "$install_dir/.env" ynh_script_progression --message="Upgrading $app..." --weight=1 # Install dependencies and aeneria -pushd $install_dir - ynh_exec_as $app php$phpversion bin/console cache:clear -n - ynh_exec_as $app php$phpversion bin/console doctrine:migrations:migrate -n +pushd "$install_dir" + ynh_exec_as "$app" "php$phpversion" bin/console cache:clear -n + ynh_exec_as "$app" "php$phpversion" bin/console doctrine:migrations:migrate -n # Set admin user mail=$(ynh_user_get_info --username="$admin" --key='mail') - user_exists=$(ynh_exec_as $app php$phpversion bin/console aeneria:user:exist "$mail") - if [ $user_exists -eq 0 ] + user_exists=$(ynh_exec_as "$app" "php$phpversion" bin/console aeneria:user:exist "$mail") + if [ "$user_exists" -eq 0 ] then - user_pass=$(ynh_string_random) - ynh_exec_as $app php$phpversion bin/console aeneria:user:add "$mail" "$user_pass" -n + default_password=$(ynh_string_random) + ynh_app_setting_set --app="$app" --key=default_password --value="$default_password" + ynh_exec_as "$app" "php$phpversion" bin/console aeneria:user:add "$mail" "$default_password" -n + ynh_print_info --message="An æneria user as been created. Your login: $mail Your password: $default_password" fi # Regenerate RSA keys - ynh_exec_as $app php$phpversion bin/console aeneria:generate-key --force -n + ynh_exec_as "$app" "php$phpversion" bin/console aeneria:generate-key --force -n popd #=================================================