diff --git a/scripts/backup b/scripts/backup index 7645bce..f57412d 100755 --- a/scripts/backup +++ b/scripts/backup @@ -19,7 +19,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Backing up Lychee..." +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -71,4 +71,4 @@ ynh_mysql_dump_db --database="$db_name" > db.sql # END OF SCRIPT #================================================= -ynh_print_info --message="Backup script completed for Lychee. (YunoHost will then actually copy those files to the archive)." +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index d88a31b..f76a1eb 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -106,4 +106,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for Lychee" --last +ynh_script_progression --message="Change of URL completed for $app" --last 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..51a327f 100755 --- a/scripts/restore +++ b/scripts/restore @@ -48,41 +48,37 @@ test ! -d $final_path \ 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_restore_file --origin_path="$final_path" - #================================================= # RECREATE THE DEDICATED USER #================================================= ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 # Create the dedicated user (if not existing) -ynh_system_user_create --username=$app +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= -# RESTORE DATA +# RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring Lychee data..." +ynh_script_progression --message="Restoring the app main directory..." --weight=2 -# 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 +ynh_restore_file --origin_path="$final_path" -#================================================= -# 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 +#================================================= +# RESTORE DATA +#================================================= +ynh_script_progression --message="Restoring the data directory..." + +# 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 + +chmod 755 "$public_path" +chmod -R o-rwx "$public_path" +chown -R $app:www-data "$public_path" #================================================= # REINSTALL DEPENDENCIES @@ -126,4 +122,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..faea48f 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -66,6 +66,8 @@ fi if [ -z "$public_path" ]; then public_path=/home/yunohost.app/$app mkdir -p $public_path + chmod 755 $public_path + chown -R $app:www-data $public_path ynh_app_setting_set --app=$app --key=public_path --value=$public_path cp -a "$final_path/public/uploads" "$public_path/uploads" fi @@ -94,10 +96,11 @@ 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" +chmod 750 "$final_path/bootstrap/cache" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" @@ -134,22 +137,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\" @@ -157,13 +155,6 @@ ynh_exec_warn_less ynh_composer_exec --commands=\"dump-autoload\" ( cd $final_path && php$phpversion artisan config:clear -n ) ( cd $final_path && php$phpversion artisan config:cache -n ) -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - -chown -R $app:www-data $public_path -chmod 755 $public_path - #================================================= # RELOAD NGINX #================================================= @@ -175,4 +166,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