From fbe9509e861fe14c557da2527fa7b75753b0e7f1 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Mon, 25 Mar 2024 20:38:08 +0100 Subject: [PATCH] change the way the __KEY__ is configured --- conf/.env.example | 4 ++-- scripts/install | 5 ++++- scripts/upgrade | 15 +++++++++------ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/conf/.env.example b/conf/.env.example index 37629a2..ee76e8b 100644 --- a/conf/.env.example +++ b/conf/.env.example @@ -26,7 +26,7 @@ SITE_OWNER=__EMAIL__ # Otherwise, change it to a string of exactly 32 chars or use command # `php artisan key:generate` to generate it. -APP_KEY= +APP_KEY=__KEY__ # This variable must match your installation's external address. @@ -39,7 +39,7 @@ APP_URL=http://__DOMAIN__ # uncomment the following line and set this var with the CDN url. # Otherwise, let this line commented. -ASSET_URL=/ +ASSET_URL=http://__DOMAIN__ # The domain subdirectory from which you want to serve 2FAuth. diff --git a/scripts/install b/scripts/install index 6178fe0..08df151 100755 --- a/scripts/install +++ b/scripts/install @@ -26,6 +26,10 @@ ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage +# key for the .env __KEY__ +key=$(ynh_string_random --length=45 | base64) +ynh_app_setting_set --app=$app --key=key --value=$key + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -75,7 +79,6 @@ pushd $install_dir php$phpversion artisan passport:install -n php$phpversion artisan storage:link -n php$phpversion artisan config:cache -n - php$phpversion artisan key:generate -n popd chmod 775 "$install_dir" diff --git a/scripts/upgrade b/scripts/upgrade index 379d99c..cb8aa89 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -38,6 +38,11 @@ if [ -z "${fpm_usage:-}" ]; then ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage fi +if [ -z "${key:-}" ]; then + key=$(ynh_string_random --length=45 | base64) + ynh_app_setting_set --app=$app --key=key --value=$key +fi + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -65,15 +70,13 @@ ynh_add_nginx_config #================================================= # ADD A CONFIGURATION #================================================= -#ynh_script_progression --message="Adding a configuration file..." --weight=1 - -#email=$(ynh_user_get_info --username=$admin --key=mail) +ynh_script_progression --message="Upgrading a configuration file..." --weight=1 # Setup application config -#ynh_add_config --template=".env.example" --destination="$install_dir/.env" +ynh_add_config --template=".env.example" --destination="$install_dir/.env" -#chmod 644 "$install_dir/.env" -#chown $app:$app "$install_dir/.env" +chmod 644 "$install_dir/.env" +chown $app:$app "$install_dir/.env" #================================================= # INSTALL 2FAUTH WITH COMPOSER