mirror of
https://github.com/YunoHost-Apps/cops_ynh.git
synced 2024-09-03 18:25:57 +02:00
Cleaning
This commit is contained in:
parent
5791047de5
commit
3c4b9fc21a
3 changed files with 38 additions and 49 deletions
|
@ -1,25 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Exit on command errors and treat unset variables as an error
|
||||
#set -eu
|
||||
|
||||
#TRAP_ON () { # Activate signal capture
|
||||
# trap EXIT_PROPERLY ERR # Capturing ex it signals on error
|
||||
#}
|
||||
|
||||
# Active trap pour arrêter le script si une erreur est détectée.
|
||||
#TRAP_ON
|
||||
|
||||
# See comments in install script
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Source YunoHost helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
path=$(ynh_app_setting_get $app path)
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
is_public=$(ynh_app_setting_get $app is_public)
|
||||
finalnginxconf=$(ynh_app_setting_get $app finalnginxconf)
|
||||
finalphpconf=$(ynh_app_setting_get $app finalphpconf)
|
||||
|
||||
|
@ -27,15 +13,6 @@ finalphpconf=$(ynh_app_setting_get $app finalphpconf)
|
|||
# Note: the last argument is where to save this path, see the restore script.
|
||||
ynh_backup "$final_path" "sources"
|
||||
|
||||
### MySQL (remove if not used) ###
|
||||
# If a MySQL database is used:
|
||||
# # Dump the database
|
||||
# dbname=$app
|
||||
# dbuser=$app
|
||||
# dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||
# mysqldump -u "$dbuser" -p"$dbpass" --no-create-db "$dbname" > ./dump.sql
|
||||
### MySQL end ###
|
||||
|
||||
# Copy NGINX configuration
|
||||
ynh_backup "$finalnginxconf" "nginx.conf"
|
||||
|
||||
|
|
|
@ -2,10 +2,42 @@
|
|||
#set -eu
|
||||
|
||||
# Charge les fonctions génériques habituellement utilisées dans le script
|
||||
source .fonctions
|
||||
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$
|
||||
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_SYS_USER () { # Supprime l'utilisateur système dédié à l'app
|
||||
if ynh_system_user_exists "$1" # Test l'existence de l'utilisateur
|
||||
then
|
||||
sudo userdel $1
|
||||
fi
|
||||
}
|
||||
|
||||
# Active trap pour arrêter le script si une erreur est détectée.
|
||||
#TRAP_ON
|
||||
|
||||
# Source app helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
|
@ -13,11 +45,6 @@ source /usr/share/yunohost/helpers
|
|||
# We retrieve app parameters
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# We check variables are not empty
|
||||
CHECK_VAR "$app" "app name not set"
|
||||
|
||||
path=$(ynh_app_setting_get $app path)
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
finalnginxconf=$(ynh_app_setting_get $app finalnginxconf)
|
||||
finalphpconf=$(ynh_app_setting_get $app finalphpconf)
|
||||
|
@ -42,9 +69,10 @@ if ynh_package_is_installed "cops-deps"; then
|
|||
ynh_package_autoremove "cops-deps"
|
||||
fi
|
||||
|
||||
# Remove the user account
|
||||
id "$runninguser" >/dev/null 2>&1 \
|
||||
&& sudo deluser --quiet "$runninguser" >/dev/null
|
||||
# Remove the user account~
|
||||
#id "$runninguser" >/dev/null 2>&1 \
|
||||
#&& sudo deluser --quiet "$runninguser" >/dev/null
|
||||
REMOVE_SYS_USER "$runninguser"
|
||||
|
||||
# We reload the services
|
||||
sudo service php5-fpm reload
|
||||
|
|
|
@ -1,19 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Note: each files and directories you've saved using the ynh_backup helper
|
||||
# will be located in the current directory, regarding the last argument.
|
||||
|
||||
# Exit on command errors and treat unset variables as an error
|
||||
#set -eu
|
||||
|
||||
#TRAP_ON () { # Activate signal capture
|
||||
# trap EXIT_PROPERLY ERR # Capturing ex it signals on error
|
||||
#}
|
||||
|
||||
# Active trap pour arrêter le script si une erreur est détectée.
|
||||
#TRAP_ON
|
||||
|
||||
# See comments in install script
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Source YunoHost helpers
|
||||
|
@ -21,8 +7,6 @@ source /usr/share/yunohost/helpers
|
|||
|
||||
# Retrieve old app settings
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
path=$(ynh_app_setting_get $app path)
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
is_public=$(ynh_app_setting_get $app is_public)
|
||||
finalnginxconf=$(ynh_app_setting_get $app finalnginxconf)
|
||||
finalphpconf=$(ynh_app_setting_get $app finalphpconf)
|
||||
|
|
Loading…
Add table
Reference in a new issue