1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/lychee_ynh.git synced 2024-09-03 19:36:36 +02:00

Handle APP_KEY environment parameter

This commit is contained in:
tituspijean 2022-01-17 11:30:38 +01:00
parent 8c1703ceaa
commit 3ff5f75391
No known key found for this signature in database
GPG key ID: EF3B0D7CC0A94720
3 changed files with 23 additions and 3 deletions

View file

@ -1,6 +1,6 @@
APP_NAME=Lychee APP_NAME=Lychee
APP_ENV=production APP_ENV=production
APP_KEY= APP_KEY=__APP_KEY__
APP_DEBUG=false APP_DEBUG=false
APP_URL=http://localhost APP_URL=http://localhost

View file

@ -128,9 +128,12 @@ ynh_install_composer --install_args="--ignore-platform-reqs"
#================================================= #=================================================
ynh_script_progression --message="Building..." --weight=10 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 # Setup application config
ynh_add_config --template="../conf/.env.example" --destination="$final_path/.env" ynh_add_config --template="../conf/.env.example" --destination="$final_path/.env"
# Setup application config # Setup application config
pushd $final_path pushd $final_path
php$phpversion artisan key:generate -n --force --env php$phpversion artisan key:generate -n --force --env

View file

@ -22,6 +22,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
datadir=$(ynh_app_setting_get --app=$app --key=datadir) datadir=$(ynh_app_setting_get --app=$app --key=datadir)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) 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 phpversion=$YNH_PHP_VERSION
#================================================= #=================================================
@ -62,7 +63,7 @@ if [ -z "$final_path" ]; then
fi fi
# If new datadir doesn't exist, create it # 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 datadir=/home/yunohost.app/$app
mkdir -p $datadir mkdir -p $datadir
chmod 755 $datadir chmod 755 $datadir
@ -71,6 +72,12 @@ if [ -z "/home/yunohost.app/$app" ]; then
cp -a "$final_path/public/uploads" "$datadir/uploads" cp -a "$final_path/public/uploads" "$datadir/uploads"
fi 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 # Cleaning legacy permissions
if ynh_legacy_permissions_exists; then if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all ynh_legacy_permissions_delete_all
@ -103,6 +110,16 @@ chmod 750 "$final_path/bootstrap/cache"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$final_path"
chown -R $app:www-data "$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 # NGINX CONFIGURATION
#================================================= #=================================================