mirror of
https://github.com/YunoHost-Apps/flarum_ynh.git
synced 2024-09-03 18:36:24 +02:00
Update remove for composer in /opt
This commit is contained in:
parent
fb0d962ea4
commit
ac87c43f41
1 changed files with 49 additions and 13 deletions
|
@ -6,22 +6,61 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
# Source YunoHost helpers
|
# Source YunoHost helpers
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
SECURE_REMOVE () { # Suppression de dossier avec vérification des variables
|
||||||
|
chaine="$1" # L'argument doit être donné entre quotes simple '', pour éviter d'interpréter les variables.
|
||||||
|
no_var=0
|
||||||
|
while (echo "$chaine" | grep -q '\$') # Boucle tant qu'il y a des $ dans la chaine
|
||||||
|
do
|
||||||
|
no_var=1
|
||||||
|
global_var=$(echo "$chaine" | cut -d '$' -f 2) # Isole la première variable trouvée.
|
||||||
|
only_var=\$$(expr "$global_var" : '\([A-Za-z0-9_]*\)') # Isole complètement la variable en ajoutant le $ au début et en gardant uniquement le nom de la variable. Se débarrasse surtout du / et d'un éventuel chemin derrière.
|
||||||
|
real_var=$(eval "echo ${only_var}") # `eval "echo ${var}` permet d'interpréter une variable contenue dans une variable.
|
||||||
|
if test -z "$real_var" || [ "$real_var" = "/" ]; then
|
||||||
|
echo "Variable $only_var is empty, suppression of $chaine cancelled." >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
chaine=$(echo "$chaine" | sed "s@$only_var@$real_var@") # remplace la variable par sa valeur dans la chaine.
|
||||||
|
done
|
||||||
|
if [ "$no_var" -eq 1 ]
|
||||||
|
then
|
||||||
|
if [ -e "$chaine" ]; then
|
||||||
|
echo "Delete directory $chaine"
|
||||||
|
sudo rm -r "$chaine"
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
echo "No detected variable." >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
REMOVE_NGINX_CONF () { # Suppression de la configuration nginx
|
||||||
|
if [ -e "/etc/nginx/conf.d/$domain.d/$app.conf" ]; then # Delete nginx config
|
||||||
|
echo "Delete nginx config"
|
||||||
|
sudo rm "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
REMOVE_FPM_CONF () { # Suppression de la configuration du pool php-fpm
|
||||||
|
if [ -e "/etc/php5/fpm/pool.d/$app.conf" ]; then # Delete fpm config
|
||||||
|
echo "Delete fpm config"
|
||||||
|
sudo rm "/etc/php5/fpm/pool.d/$app.conf"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Retrieve app settings
|
# Retrieve app settings
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
|
|
||||||
# Remove sources
|
# Remove sources
|
||||||
sudo rm -rf /tmp/composerinstall
|
SECURE_REMOVE "/tmp/composerinstall"
|
||||||
sudo rm -rf /var/www/$app
|
SECURE_REMOVE "/var/www/$app"
|
||||||
sudo rm -rf /opt/flarum_composer
|
SECURE_REMOVE "/opt/${app}_composer"
|
||||||
|
|
||||||
# Remove nginx configuration file
|
# Remove nginx and PHP-FPM files and restart services
|
||||||
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
|
REMOVE_NGINX_CONF
|
||||||
|
REMOVE_FPM_CONF
|
||||||
### PHP ###
|
sudo service nginx reload
|
||||||
# If a dedicated php-fpm process is used:
|
|
||||||
sudo rm -f /etc/php5/fpm/pool.d/$app.conf
|
|
||||||
sudo service php5-fpm reload
|
sudo service php5-fpm reload
|
||||||
### PHP end ###
|
|
||||||
|
|
||||||
### MySQL ###
|
### MySQL ###
|
||||||
# If a MySQL database is used:
|
# If a MySQL database is used:
|
||||||
|
@ -31,6 +70,3 @@ dbuser=$app
|
||||||
ynh_mysql_drop_db "$dbname" || true
|
ynh_mysql_drop_db "$dbname" || true
|
||||||
ynh_mysql_drop_user "$dbuser" || true
|
ynh_mysql_drop_user "$dbuser" || true
|
||||||
### MySQL end ###
|
### MySQL end ###
|
||||||
|
|
||||||
# Reload nginx service
|
|
||||||
sudo service nginx reload
|
|
||||||
|
|
Loading…
Reference in a new issue