1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/z-push_ynh.git synced 2024-09-03 18:05:58 +02:00

Big update on install script

This commit is contained in:
polytan02 2017-01-18 00:23:21 +00:00
parent ec8a84e4a2
commit 8b9e56f560

View file

@ -1,22 +1,82 @@
#!/bin/bash #!/bin/bash
# Retrieve arguments # Active trap pour arrêter le script si une erreur est détectée.
domain=$YNH_APP_ARG_DOMAIN EXIT_PROPERLY () { # Provoque l'arrêt du script en cas d'erreur. Et nettoye les résidus.
#path=$YNH_APP_ARG_PATH exit_code=$?
app=$YNH_APP_INSTANCE_NAME if [ "$exit_code" -eq 0 ]; then
exit 0 # Quitte sans erreur si le script se termine correctement.
fi
trap '' EXIT
set +eu
echo -e "\e[91m \e[1m" # Shell in light red bold
echo -e "!!\n $app install's script has encountered an error. Installation was cancelled.\n!!" >&2
# Check domain/path availability if type -t CLEAN_SETUP > /dev/null; then # Vérifie l'existance de la fonction avant de l'exécuter.
sudo yunohost app checkurl $domain$path -a $app CLEAN_SETUP # Appel la fonction de nettoyage spécifique du script install.
if [[ ! $? -eq 0 ]]; then fi
exit 1
fi # Compense le bug de ssowat qui ne supprime pas l'entrée de l'app en cas d'erreur d'installation.
sudo sed -i "\@\"$domain$path/\":@d" /etc/ssowat/conf.json
ynh_die
}
TRAP_ON () { # Activate signal capture
set -eu # Exit if a command fail, and if a variable is used unset.
trap EXIT_PROPERLY EXIT # Capturing exit signals on shell script
}
TRAP_ON
# Source app helpers
source /usr/share/yunohost/helpers
# Retrieve arguments
app=$YNH_APP_INSTANCE_NAME
domain=$YNH_APP_ARG_DOMAIN
path="/Microsoft-Server-ActiveSync"
# We check variables are not empty
CHECK_VAR () { # Vérifie que la variable n'est pas vide.
# $1 = Variable à vérifier
# $2 = Texte à afficher en cas d'erreur
test -n "$1" || (echo "$2" >&2 && false)
}
CHECK_VAR "$app" "app name not set"
# Check domain and path availibility
CHECK_DOMAINPATH () { # Vérifie la disponibilité du path et du domaine.
sudo yunohost app checkurl $domain$path -a $app
}
CHECK_DOMAINPATH
# Prereqs # Prereqs
sudo apt-get install php-soap php5-imap libawl-php php5-xsl -y sudo apt-get install php-soap php5-imap libawl-php php5-xsl -y
final_logpath=/var/log/$app
final_path=/var/www/$app final_path=/var/www/$app
CHECK_FINALPATH () { # Vérifie que le dossier de destination n'est pas déjà utilisé.
if [ -e "$final_path" ]
then
echo "This path already contains a folder" >&2
false
fi
}
CHECK_FINALPATH
final_logpath=/var/log/$app
# Define variables and Save app settings
ynh_app_setting_set "$app" domain "$domain"
ynh_app_setting_set "$app" final_logpath "$final_logpath"
ynh_app_setting_set "$app" final_path "$final_path"
# Copy files to the right place # Copy files to the right place
sudo mkdir -p $final_path sudo mkdir -p $final_path
sudo cp -a ../sources/* $final_path sudo cp -a ../sources/* $final_path
@ -85,8 +145,8 @@ sudo cp ../conf/php-fpm.conf $finalphpconf
sudo chown root: $finalphpconf sudo chown root: $finalphpconf
sudo chmod 644 $finalphpconf sudo chmod 644 $finalphpconf
# Enable api for client # Enable api for client and make app public
sudo yunohost app setting $app skipped_uris -v "/" ynh_app_setting_set $app skipped_uris "/"
# Reload Nginx and regenerate SSOwat conf # Reload Nginx and regenerate SSOwat conf
sudo service php5-fpm reload sudo service php5-fpm reload