From 13d0d4b88e6c361c116a988763df374bb3974338 Mon Sep 17 00:00:00 2001 From: anmol26s Date: Mon, 4 Jun 2018 18:44:50 +0530 Subject: [PATCH] Dedicated php-fpm for upgrade,retore,backup --- scripts/backup | 7 +++++++ scripts/restore | 6 +++--- scripts/upgrade | 38 +++++++++++++++++++++++++++++--------- 3 files changed, 39 insertions(+), 12 deletions(-) diff --git a/scripts/backup b/scripts/backup index 87bed35..c520c2d 100644 --- a/scripts/backup +++ b/scripts/backup @@ -45,6 +45,13 @@ ynh_backup "$final_path" ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" +#================================================= +# BACKUP THE PHP-FPM CONFIGURATION +#================================================= + +ynh_backup "/etc/php5/fpm/pool.d/$app.conf" +ynh_backup "/etc/php5/fpm/conf.d/20-$app.ini" + #================================================= # BACKUP THE MYSQL DATABASE diff --git a/scripts/restore b/scripts/restore index d333aff..64ab973 100644 --- a/scripts/restore +++ b/scripts/restore @@ -71,11 +71,11 @@ ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql ynh_system_user_create $app #================================================= -# RESTORE USER RIGHTS +# RESTORE THE PHP-FPM CONFIGURATION #================================================= -# Restore permissions on app files -chown -R root: $final_path +ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf" +ynh_restore_file "/etc/php5/fpm/conf.d/20-$app.ini" #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index cc40e02..cf6445e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -41,7 +41,6 @@ if [ -z $db_name ]; then ynh_app_setting_set $app db_name $db_name fi - # If final_path doesn't exist, create it if [ -z $final_path ]; then final_path=/var/www/$app @@ -75,17 +74,30 @@ path_url=$(ynh_normalize_url_path $path_url) #================================================= # Download, check integrity, uncompress and patch the source from app.src +# Create a temporary directory +tmpdir="$(mktemp -d)" + +# Backup the config file in the temp dir +cp -a "$final_path/config.php" "$tmpdir/config.php" + +# Remove the app directory securely +ynh_secure_remove "$final_path" + +# If final_path doesn't exist, create it +if [ -z $final_path ]; then + final_path=/var/www/$app + ynh_app_setting_set $app final_path $final_path +fi + #ynh_setup_source "$final_path" -#move the final_path to final_path.old -sudo mv ${final_path} ${final_path}.old -sudo mkdir -p $final_path ynh_setup_source "$final_path" -#copy cofig.php from final_path.old to final_path -sudo cp -a ${final_path}.old/config.php ${final_path} -#remove final_path.old -sudo rm -Rf ${final_path}.old +#copy cofig.php from tmp to final_path +sudo cp -a "$tmpdir/config.php" "${final_path}" + +#remove tmp dir +sudo rm -Rf "$tmpdir" #================================================= @@ -95,6 +107,7 @@ sudo rm -Rf ${final_path}.old # Create a dedicated nginx config ynh_add_nginx_config + #================================================= # CREATE DEDICATED USER #================================================= @@ -102,6 +115,13 @@ ynh_add_nginx_config # Create a system user ynh_system_user_create $app +#================================================= +# PHP-FPM CONFIGURATION +#================================================= + +# Create a dedicated php-fpm config +ynh_add_fpm_config + #================================================= @@ -123,7 +143,7 @@ ynh_store_file_checksum "$final_path/config.php" #================================================= # Set right permissions for curl installation -chown -R root: $final_path +chown -R $app: $final_path #================================================= # SETUP SSOWAT