diff --git a/scripts/install b/scripts/install index 4b4954c..4fc47ad 100755 --- a/scripts/install +++ b/scripts/install @@ -68,6 +68,14 @@ db_user=$db_name ynh_app_setting_set --app=$app --key=db_name --value=$db_name ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." + +# Create a system user +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -77,6 +85,11 @@ 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" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" +#chmod -R 700 $final_path/data + #================================================= # NGINX CONFIGURATION #================================================= @@ -85,14 +98,6 @@ ynh_script_progression --message="Configuring NGINX web server..." # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." - -# Create a system user -ynh_system_user_create --username=$app - #================================================= # PHP-FPM CONFIGURATION #================================================= @@ -109,9 +114,6 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) # Adding the details of the database to the config file ynh_add_config --template="../conf/config.ini.php" --destination="$final_path/data/config.ini.php" -# # Copy the config file to the final path -# cp ../conf/config.ini.php $final_path/data/. - # Load initial SQL into the new database ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" < "../conf/sql/webtrees.sql" @@ -123,16 +125,6 @@ ynh_replace_string --match_string="__PASSWORD__" --replace_string="$admin_pass ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" < "../conf/sql/admin.sql" -#================================================= -# GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - -# Set permissions to app files -chown -R $app: $final_path -chmod -R 700 $final_path/data - #================================================= # SETUP SSOWAT #================================================= diff --git a/scripts/restore b/scripts/restore index fc63a56..b6c473c 100644 --- a/scripts/restore +++ b/scripts/restore @@ -44,15 +44,9 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Restoring the NGINX configuration..." -ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" - -#================================================= -# RESTORE THE APP MAIN DIR -#================================================= -ynh_script_progression --message="Restoring $app main directory..." - -ynh_restore_file "$final_path" +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RECREATE THE DEDICATED USER @@ -60,21 +54,25 @@ ynh_restore_file "$final_path" ynh_script_progression --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) -ynh_system_user_create $app +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= -# RESTORE USER RIGHTS +# RESTORE THE APP MAIN DIR #================================================= +ynh_script_progression --message="Restoring $app main directory..." -# Restore permissions to app files -chown -R $app: "${final_path}" -chmod -R 700 $final_path/data +ynh_restore_file --origin_path="$final_path" + +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= +ynh_script_progression --message="Restoring the PHP-FPM configuration..." -ynh_restore_file "/etc/php/$phpversion/fpm/pool.d/$app.conf" +ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" #================================================= # SPECIFIC RESTORATION @@ -102,7 +100,7 @@ ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql #================================================= ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." -ynh_systemd_action --service_name=php${phpversion}-fpm --action=reload +ynh_systemd_action --service_name=php$phpversion-fpm --action=reload ynh_systemd_action --service_name=nginx --action=reload #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 72a477f..b05a57a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -66,17 +66,17 @@ ynh_abort_if_errors #================================================= ynh_script_progression --message="Upgrading source files..." -# Move old app dir -mv ${final_path} ${final_path}.old +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + ynh_script_progression --message="Upgrading source files..." --time --weight=1 -# Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source "$final_path" + # Download, check integrity, uncompress and patch the source from app.src + ynh_setup_source --dest_dir="$final_path" --keep="$final_path/data" +fi -# restore data -cp -a ${final_path}.old/data ${final_path} - -# delete temp directory -ynh_secure_remove --file=${final_path}.old +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" #================================================= # NGINX CONFIGURATION @@ -113,19 +113,9 @@ ynh_add_fpm_config # SPECIFIC UPGRADE #================================================= -ynh_backup_if_checksum_is_different "$final_path/data/config.ini.php" -# Recalculate and store the checksum of the file for the next upgrade. -ynh_store_file_checksum "$final_path/data/config.ini.php" - -#================================================= -# GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - -# Set permissions on app files -chown -R $app: $final_path -chmod -R 700 $final_path/data +# ynh_backup_if_checksum_is_different "$final_path/data/config.ini.php" +# # Recalculate and store the checksum of the file for the next upgrade. +# ynh_store_file_checksum "$final_path/data/config.ini.php" #================================================= # GENERIC FINALIZATION