diff --git a/conf/.env b/conf/.env index 715541e..7a447f3 100644 --- a/conf/.env +++ b/conf/.env @@ -3,7 +3,7 @@ # -------------------------------------------- APP_ENV=production APP_DEBUG=false -APP_KEY=__KEY__ +APP_KEY=__APP_KEY__ APP_URL=http://__DOMAIN__ APP_TIMEZONE='UTC' APP_LOCALE=__LANGUAGE__ diff --git a/scripts/install b/scripts/install index cead50b..efdaa02 100755 --- a/scripts/install +++ b/scripts/install @@ -31,9 +31,6 @@ admin=$YNH_APP_ARG_ADMIN app=$YNH_APP_INSTANCE_NAME -email=$(ynh_user_get_info --username=$admin --key=mail) -key=$(ynh_string_random --length=24) - #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= @@ -127,6 +124,7 @@ ynh_script_progression --message="Adding a configuration file..." redis_db=$(ynh_redis_get_free_db) ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db" +app_key="" ynh_add_config --template="../conf/.env" --destination="$final_path/.env" chmod 600 "$final_path/.env" @@ -145,6 +143,10 @@ pushd "$final_path" php$phpversion artisan config:cache -n popd +app_key="$(grep "^APP_KEY=" "$final_path/.env" | cut -d= -f2)" +ynh_app_setting_set --app=$app --key=app_key --value=$app_key +ynh_store_file_checksum --file="$final_path/.env" + # Set permissions to app files chown -R $app:www-data $final_path chmod -R o-rwx $final_path diff --git a/scripts/upgrade b/scripts/upgrade index a62dcea..85bbf72 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -23,6 +23,7 @@ admin=$(ynh_app_setting_get --app=$app --key=admin) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +app_key=$(ynh_app_setting_get --app=$app --key=app_key) #================================================= # CHECK VERSION @@ -71,6 +72,12 @@ if [ -z "$final_path" ]; then ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi +# If app_key doesn't exist, create it +if [ -z "$app_key" ]; then + app_key="$(grep "^APP_KEY=" "$final_path/.env" | cut -d= -f2)" + ynh_app_setting_set --app=$app --key=app_key --value=$app_key +fi + #================================================= # CREATE DEDICATED USER #=================================================