mirror of
https://github.com/YunoHost-Apps/prestashop_ynh.git
synced 2024-09-03 20:06:39 +02:00
Refactoring de backup/remove
This commit is contained in:
parent
2316d91531
commit
4598396ccd
2 changed files with 38 additions and 41 deletions
|
@ -3,30 +3,28 @@
|
|||
# Exit on command errors and treat unset variables as an error
|
||||
set -eu
|
||||
|
||||
# The parameter $1 is the backup directory location dedicated to the app
|
||||
backup_dir=$1
|
||||
|
||||
# The parameter $2 is theid of the app instance
|
||||
app=$2
|
||||
# Get multi-instances specific variables
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Source app helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
# Retrieve app settings
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
with_mysql=$(ynh_app_setting_get "$app" with_mysql)
|
||||
|
||||
# Copy the app files
|
||||
sudo mkdir -p ${backup_dir}/var/www
|
||||
sudo cp -a $final_path "${backup_dir}/var/www/$app"
|
||||
final_path="/var/www/${app}"
|
||||
ynh_backup "$final_path" "sources" 1
|
||||
|
||||
# Copy the conf files
|
||||
sudo mkdir -p "${backup_dir}/conf"
|
||||
sudo cp -a /etc/nginx/conf.d/$domain.d/$app.conf "${backup_dir}/conf/nginx.conf"
|
||||
|
||||
# Copy dedicated php-fpm process to backup folder
|
||||
sudo cp -a /etc/php5/fpm/pool.d/$app.conf "${backup_dir}/conf/php-fpm.conf"
|
||||
sudo cp -a /etc/php5/fpm/conf.d/20-$app.ini "${backup_dir}/conf/php-fpm.ini"
|
||||
# Copy the nginx conf files
|
||||
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf"
|
||||
# Copy the php-fpm conf files
|
||||
ynh_backup "/etc/php5/fpm/pool.d/${app}.conf" "php-fpm.conf"
|
||||
ynh_backup "/etc/php5/fpm/conf.d/20-${app}.ini" "php-fpm.ini"
|
||||
|
||||
# Backup db
|
||||
root_pwd=$(sudo cat /etc/yunohost/mysql)
|
||||
sudo su -c "mysqldump -u root -p$root_pwd --no-create-db $app > ${backup_dir}/db.sql"
|
||||
if [[ $with_mysql -eq 1 ]]; then
|
||||
root_pwd=$(sudo cat /etc/yunohost/mysql)
|
||||
sudo su -c "mysqldump -u root -p$root_pwd --no-create-db $app > ./db.sql"
|
||||
fi
|
|
@ -3,33 +3,32 @@
|
|||
# Exit on command errors and treat unset variables as an error
|
||||
set -u
|
||||
|
||||
source .fonctions # Charge les fonctions génériques habituellement utilisées dans le script
|
||||
|
||||
# Source app helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
|
||||
# Get multi-instances specific variables
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
# Source app helpers
|
||||
. /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# REMOVE THE SQL BDD
|
||||
#=================================================
|
||||
# Retrieve app settings
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
with_mysql=$(ynh_app_setting_get "$app" with_mysql)
|
||||
|
||||
ynh_mysql_remove_db $db_name $db_name # Suppression de la base de donnée et de l'utilisateur associé.
|
||||
# Drop MySQL database and user as needed
|
||||
if [[ $with_mysql -eq 1 ]]; then
|
||||
dbname=$app
|
||||
dbuser=$app
|
||||
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||
ynh_mysql_drop_db $dbname || true
|
||||
ynh_mysql_drop_user $dbuser || true
|
||||
fi
|
||||
|
||||
SECURE_REMOVE '/var/www/$app' # Suppression du dossier de l'application
|
||||
# Delete app directory and configurations
|
||||
sudo rm -rf "/var/www/${app}"
|
||||
sudo rm -f "/etc/php5/fpm/pool.d/${app}.conf"
|
||||
sudo rm -f "/etc/php5/fpm/conf.d/20-${app}.ini"
|
||||
[[ -n $domain ]] && sudo rm -f "/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||
|
||||
REMOVE_NGINX_CONF # Suppression de la configuration nginx
|
||||
# Reload services
|
||||
sudo service php5-fpm restart || true
|
||||
sudo service nginx reload || true
|
||||
|
||||
REMOVE_FPM_CONF # Suppression de la configuration du pool php-fpm
|
||||
|
||||
# Régénère la configuration de SSOwat
|
||||
sudo yunohost app ssowatconf
|
||||
|
||||
echo -e "\e[0m" # Restore normal color
|
||||
|
|
Loading…
Add table
Reference in a new issue