From 9a13c14cae88c243668ece401feafa7863fd3ab1 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 22 Jun 2021 23:24:34 +0200 Subject: [PATCH] fix --- scripts/install | 56 +++++++++++++++++++++++-------------------------- scripts/remove | 4 ++-- scripts/restore | 23 ++++++++------------ scripts/upgrade | 21 +++++++------------ 4 files changed, 45 insertions(+), 59 deletions(-) diff --git a/scripts/install b/scripts/install index 55f25b1..2007fa1 100755 --- a/scripts/install +++ b/scripts/install @@ -51,23 +51,23 @@ ynh_script_progression --message="Installing dependencies..." --weight=3 ynh_install_app_dependencies $pkg_dependencies -#================================================= -# CREATE A MYSQL DATABASE -#================================================= -ynh_script_progression --message="Creating a MySQL database..." - -db_name=$(ynh_sanitize_dbid --db_name=$app) -db_user=$db_name -ynh_app_setting_set --app=$app --key=db_name --value=$db_name -ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name - #================================================= # CREATE DEDICATED USER #================================================= ynh_script_progression --message="Configuring system user..." --weight=2 # Create a system user -ynh_system_user_create --username=$app +ynh_system_user_create --username=$app --home_dir="$final_path" + +#================================================= +# CREATE A MYSQL DATABASE +#================================================= +ynh_script_progression --message="Creating a MySQL database..." --weight=2 + +db_name=$(ynh_sanitize_dbid --db_name=$app) +db_user=$db_name +ynh_app_setting_set --app=$app --key=db_name --value=$db_name +ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -76,11 +76,17 @@ ynh_script_progression --message="Setting up source files..." --weight=3 ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir=$final_path +ynh_setup_source --dest_dir="$final_path" + +chmod 750 "$final_path" +chmod 750 "$final_path/bootstrap/cache" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" #================================================= -# CREATE DIRECTORIES +# CREATE DATA DIRECTORY #================================================= +ynh_script_progression --message="Creating a data directory..." --weight=1 public_path=/home/yunohost.app/$app ynh_app_setting_set --app=$app --key=public_path --value=$public_path @@ -88,13 +94,17 @@ ynh_app_setting_set --app=$app --key=public_path --value=$public_path mkdir -p $public_path/uploads mkdir -p $public_path/uploads/{big,import,medium,raw,small,thumb} +chmod 750 "$public_path" +chmod -R o-rwx "$public_path" +chown -R $app:www-data "$public_path" + #================================================= # NGINX CONFIGURATION #================================================= ynh_script_progression --message="Configuring NGINX web server..." --weight=1 # Create a dedicated NGINX config -ynh_add_nginx_config #"public_path" +ynh_add_nginx_config #================================================= # PHP-FPM CONFIGURATION @@ -108,7 +118,7 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # INSTALL LYCHEE WITH COMPOSER #================================================= -ynh_script_progression --message="Installing Lychee with Composer..." --weight=15 +ynh_script_progression --message="Installing $app with Composer..." --weight=15 ynh_install_composer --install_args="--ignore-platform-reqs" @@ -131,20 +141,6 @@ popd # Setup custom user.css file ynh_add_config --template="../conf/user.css.example" --destination="$final_path/public/dist/user.css" -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - -# Set permissions to app files - -chmod 750 "$final_path" -chmod 750 "$final_path/bootstrap/cache" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" - -chown -R $app:www-data $public_path -chmod 755 $public_path - #================================================= # SETUP SSOWAT #================================================= @@ -167,4 +163,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of Lychee completed" --last +ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index 4a66c7f..c6c1d45 100755 --- a/scripts/remove +++ b/scripts/remove @@ -27,7 +27,7 @@ db_user=$db_name #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing Lychee main directory..." --weight=3 +ynh_script_progression --message="Removing app main directory..." --weight=3 # Remove the app directory securely ynh_secure_remove --file="$final_path" @@ -78,4 +78,4 @@ ynh_system_user_delete --username=$app # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of Lychee completed" --last +ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore index 19a4783..a0630a7 100755 --- a/scripts/restore +++ b/scripts/restore @@ -51,10 +51,15 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring Lychee main directory..." --weight=2 +ynh_script_progression --message="Restoring the app main directory..." --weight=2 ynh_restore_file --origin_path="$final_path" +chmod 750 "$final_path" +chmod 750 "$final_path/bootstrap/cache" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" + #================================================= # RECREATE THE DEDICATED USER #================================================= @@ -66,23 +71,13 @@ ynh_system_user_create --username=$app #================================================= # RESTORE DATA #================================================= -ynh_script_progression --message="Restoring Lychee data..." +ynh_script_progression --message="Restoring $app data..." # Use --not_mandatory for the data directory, because if the backup has been made with BACKUP_CORE_ONLY, there's no data into the backup. ynh_restore_file --origin_path="$public_path" --not_mandatory -#================================================= -# RESTORE USER RIGHTS -#================================================= - -# Set permissions to app files -chmod 750 "$final_path" -chmod 750 "$final_path/bootstrap/cache" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" - -chown -R $app:www-data $public_path chmod 755 $public_path +chown -R $app:www-data $public_path #================================================= # REINSTALL DEPENDENCIES @@ -126,4 +121,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for Lychee" --last +ynh_script_progression --message="Restoration completed for $app" --last diff --git a/scripts/upgrade b/scripts/upgrade index f1efe6f..7108994 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -94,7 +94,7 @@ then ynh_script_progression --message="Upgrading source files..." --weight=4 # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" --keep="$final_path/public/dist/user.css $final_path/.env" + ynh_setup_source --dest_dir="$final_path" fi chmod 750 "$final_path" @@ -134,22 +134,17 @@ ynh_install_composer --install_args="--ignore-platform-reqs" #================================================= # SETUP APPLICATION CONFIG #================================================= -# ynh_script_progression --message="Setting Lychee config..." +ynh_script_progression --message="Setting $app 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" + +ynh_add_config --template="../conf/user.css.example" --destination="$final_path/public/dist/user.css" #================================================= # INSTALL AND INITIALIZE COMPOSER #================================================= -ynh_script_progression --message="Upgrading Lychee source files..." --weight=4 - -# pushd $final_path -# php$phpversion artisan key:generate -n --force --env -# php$phpversion artisan migrate -n --force -# php$phpversion artisan config:clear -n -# php$phpversion artisan config:cache -n -# popd +ynh_script_progression --message="Upgrading $app source files..." --weight=4 ynh_exec_warn_less ynh_composer_exec --commands=\"dump-autoload\" @@ -161,8 +156,8 @@ ynh_exec_warn_less ynh_composer_exec --commands=\"dump-autoload\" # SECURE FILES AND DIRECTORIES #================================================= -chown -R $app:www-data $public_path chmod 755 $public_path +chown -R $app:www-data $public_path #================================================= # RELOAD NGINX @@ -175,4 +170,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of Lychee completed" --last +ynh_script_progression --message="Upgrade of $app completed" --last