diff --git a/conf/.env.example b/conf/.env.example index 8c39b67..d8fdbaa 100644 --- a/conf/.env.example +++ b/conf/.env.example @@ -1,6 +1,6 @@ APP_NAME=Lychee APP_ENV=production -APP_KEY= +APP_KEY=__APP_KEY__ APP_DEBUG=false APP_URL=http://localhost diff --git a/scripts/install b/scripts/install index d1c4688..7a6b3e0 100755 --- a/scripts/install +++ b/scripts/install @@ -128,9 +128,12 @@ ynh_install_composer --install_args="--ignore-platform-reqs" #================================================= ynh_script_progression --message="Building..." --weight=10 +app_key=$(ynh_string_random --length=32) +ynh_app_setting_set --app=$app --key=app_key --value=$app_key + # Setup application config ynh_add_config --template="../conf/.env.example" --destination="$final_path/.env" - + # Setup application config pushd $final_path php$phpversion artisan key:generate -n --force --env diff --git a/scripts/upgrade b/scripts/upgrade index 9603c65..f030b84 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,6 +22,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) datadir=$(ynh_app_setting_get --app=$app --key=datadir) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) +app_key=$(ynh_app_setting_get --app=$app --key=app_key) phpversion=$YNH_PHP_VERSION #================================================= @@ -62,7 +63,7 @@ if [ -z "$final_path" ]; then fi # If new datadir doesn't exist, create it -if [ -z "/home/yunohost.app/$app" ]; then +if [ -z "/home/yunohost.app/$app" ] || [ -z "$datadir" ]; then datadir=/home/yunohost.app/$app mkdir -p $datadir chmod 755 $datadir @@ -71,6 +72,12 @@ if [ -z "/home/yunohost.app/$app" ]; then cp -a "$final_path/public/uploads" "$datadir/uploads" fi +# If app_key doesn't exist, create it +if [ -z "$app_key" ]; then + app_key=$(ynh_string_random --length=32) + ynh_app_setting_set --app=$app --key=app_key --value=$app_key +fi + # Cleaning legacy permissions if ynh_legacy_permissions_exists; then ynh_legacy_permissions_delete_all @@ -103,6 +110,16 @@ chmod 750 "$final_path/bootstrap/cache" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" +#================================================= +# UPDATE A CONFIG FILE +#================================================= +ynh_script_progression --message="Updating the environment file..." --weight=1 + +ynh_add_config --template=".env.example" --destination="$final_path/.env" + +chmod 660 "$final_path/.env" +chown $app:www-data "$final_path/.env" + #================================================= # NGINX CONFIGURATION #=================================================