From 44055144f8a9fa646f54156bb20223120de912ff Mon Sep 17 00:00:00 2001 From: frju365 Date: Wed, 8 Mar 2017 23:32:10 +0100 Subject: [PATCH] Update install --- scripts/install | 81 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 57 insertions(+), 24 deletions(-) diff --git a/scripts/install b/scripts/install index 953fb34..a85cd5f 100644 --- a/scripts/install +++ b/scripts/install @@ -1,55 +1,88 @@ #!/bin/bash -set -e +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= -source ./_common.sh +source .fonctions +source /usr/share/yunohost/helpers -app="jappix" +#================================================= +# MANAGE FAILURE OF THE SCRIPT +#================================================= -# Retrieve arguments -domain=$1 -path=${2%/} -name=$3 -language=$4 +ynh_check_error # Active trap pour arrêter le script si une erreur est détectée. +#================================================= +# RETRIEVE ARGUMENTS FROM THE MANIFEST +#================================================= + +domain=$YNH_APP_ARG_DOMAIN +path=$YNH_APP_ARG_PATH +name=$YNH_APP_ARG_NAME +language=$YNH_APP_ARG_LANGUAGE + + +app=$YNH_APP_INSTANCE_NAME +#================================================= # Check domain/path availability -sudo yunohost app checkurl "${domain}${path}" -a "$app" \ - || exit 1 +#================================================= -# Retrieve sources -wget -q -O jappix.tar.gz "$JAPPIX_SOURCE_URL" +CHECK_PATH # Vérifie et corrige la syntaxe du path. +CHECK_DOMAINPATH +CHECK_FINALPATH # Vérifie que le dossier de destination n'est pas déjà utilisé. +#================================================= +# STORE SETTINGS FROM MANIFEST +#================================================= + +ynh_app_setting_set $app name $name +ynh_app_setting_set $app language $language +ynh_app_setting_set $app domain $domain +ynh_app_setting_set $app final_path $final_path + +#================================================= # Copy files to the right place -final_path="/var/www/${app}" +#================================================= + +SETUP_SOURCE # Télécharge la source, décompresse et copie dans $final_path + sudo mkdir -p "${final_path}/store/conf" -sudo tar -C "$final_path" -xf jappix.tar.gz --strip-components 1 sudo cp ../conf/*.xml "${final_path}/store/conf/" +#================================================= # Set permissions to jappix directory +#================================================= + sudo chown -R www-data: "$final_path" +#================================================= # Set and copy NGINX configuraion -sudo sed -i "s@PATHTOCHANGE2@${path}@g" ../conf/nginx.conf -path=${path:-/} +#================================================= + sudo sed -i "s@PATHTOCHANGE@${path}@g" ../conf/nginx.conf sudo sed -i "s@ALIASTOCHANGE@${final_path}/@g" ../conf/nginx.conf sudo cp ../conf/nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf" +#================================================= # Validate language -[[ -a "${final_path}/i18n/${language}" ]] \ +#================================================= + +[[ -e "${final_path}/i18n/${language}" ]] \ || language="en" -# Store app settings -sudo yunohost app setting "$app" name -v "$name" -sudo yunohost app setting "$app" language -v "$language" - +#================================================= # Set Jappix configuration -sudo sed -i "s@PATHTOCHANGE@${path}@g" "${final_path}/store/conf/main.xml" +#================================================= + sudo sed -i "s@PATHTOCHANGE@${path}@g" "${final_path}/store/conf/hosts.xml" -sudo sed -i "s@DOMAINTOCHANGE@${domain}@g" "${final_path}/store/conf/main.xml" sudo sed -i "s@CHANGELANG@${language}@g" "${final_path}/store/conf/main.xml" sudo sed -i "s@CHANGENAME@${name}@g" "${final_path}/store/conf/main.xml" sudo sed -i "s@DOMAINTOCHANGE@${domain}@g" "${final_path}/store/conf/hosts.xml" - +#================================================= # Reload services +#================================================= + sudo service nginx reload