From c1233a5b8e850247833eb4bd6ad71bf05aae87cb Mon Sep 17 00:00:00 2001 From: frju365 Date: Wed, 8 Mar 2017 23:24:45 +0100 Subject: [PATCH 01/15] Update check_process --- check_process | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/check_process b/check_process index 31337ff..a864974 100644 --- a/check_process +++ b/check_process @@ -26,8 +26,7 @@ Level 1=auto Level 2=auto Level 3=auto -# Niveau 4 ignoré, mais c'est à confirmé par le mainteneur de l'application. - Level 4=na + Level 4=1 Level 5=auto Level 6=auto Level 7=auto From 87c35515fccf3435b7c793a9855e16050392c29d Mon Sep 17 00:00:00 2001 From: frju365 Date: Wed, 8 Mar 2017 23:25:40 +0100 Subject: [PATCH 02/15] Update README.md --- README.md | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 1f72177..3e59c2d 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,9 @@ -Jappix for Yunohost -------------------- +#Jappix package for YunoHost -**Shipped version:** 1.1.6 +- **YunoHost**: https://yunohost.org/ +- **Shipped version:** 1.1.7 -[Jappix](https://jappix.org) is a full-featured XMPP web-client +Jappix is a full-featured XMPP web-client with an open social platform which enables you to host your communication platform wherever you want to. -## Links ## - -**Jappix**: https://jappix.org/ - -**YunoHost**: https://yunohost.org/ From b7a22370fd61b4a04e58345efead858a56685384 Mon Sep 17 00:00:00 2001 From: frju365 Date: Wed, 8 Mar 2017 23:27:29 +0100 Subject: [PATCH 03/15] Create app.src --- conf/app.src | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 conf/app.src diff --git a/conf/app.src b/conf/app.src new file mode 100644 index 0000000..c461c3f --- /dev/null +++ b/conf/app.src @@ -0,0 +1,2 @@ +SOURCE_URL=https://github.com/jappix/jappix/archive/1.1.7.tar.gz +SOURCE_SUM=515b8079b42f280da9b624d8f9825109 From 8cf862f1e5aebcb49ed5e2316a4715a35127e72f Mon Sep 17 00:00:00 2001 From: frju365 Date: Wed, 8 Mar 2017 23:29:01 +0100 Subject: [PATCH 04/15] Update nginx.conf --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index f18e7b7..d8528fd 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -19,7 +19,7 @@ location PATHTOCHANGE { include conf.d/yunohost_panel.conf.inc; } -location PATHTOCHANGE2/http-bind { +location PATHTOCHANGE/http-bind { if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } From 5d7c35bc89d50e58991b39a86282ce57958d40dd Mon Sep 17 00:00:00 2001 From: frju365 Date: Wed, 8 Mar 2017 23:29:43 +0100 Subject: [PATCH 05/15] Update manifest.json --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index a92865b..1962914 100644 --- a/manifest.json +++ b/manifest.json @@ -8,7 +8,7 @@ }, "url": "https://jappix.org/", "license": "AGPL-3", - "version": "1.1.6", + "version": "1.1.7", "maintainer": { "name": "titoko", "email": "titoko@titoko.fr" From 961ea8816f82f47d2234fe798b8ad60609535ef2 Mon Sep 17 00:00:00 2001 From: frju365 Date: Wed, 8 Mar 2017 23:30:26 +0100 Subject: [PATCH 06/15] Create .fonctions --- scripts/.fonctions | 95 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 scripts/.fonctions diff --git a/scripts/.fonctions b/scripts/.fonctions new file mode 100644 index 0000000..6872e5f --- /dev/null +++ b/scripts/.fonctions @@ -0,0 +1,95 @@ +#!/bin/bash + +#================================================= +# CHECKING +#================================================= + +CHECK_PATH () { # Vérifie la présence du / en début de path. Et son absence à la fin. + if [ "${path:0:1}" != "/" ]; then # Si le premier caractère n'est pas un / + path="/$path" # Ajoute un / en début de path + fi + if [ "${path:${#path}-1}" == "/" ] && [ ${#path} -gt 1 ]; then # Si le dernier caractère est un / et que ce n'est pas le seul caractère. + path="${path:0:${#path}-1}" # Supprime le dernier caractère + fi +} + +CHECK_DOMAINPATH () { # Vérifie la disponibilité du path et du domaine. + sudo yunohost app checkurl $domain$path -a $app +} + +CHECK_FINALPATH () { # Vérifie que le dossier de destination n'est pas déjà utilisé. + final_path=/var/www/$app + test ! -e "$final_path" || ynh_die "This path already contains a folder" +} + +#================================================= +# SETUP +#================================================= + +SETUP_SOURCE () { # Télécharge la source, décompresse et copie dans $final_path + src_url=$(cat ../conf/app.src | grep SOURCE_URL | cut -d= -f2) + src_checksum=$(cat ../conf/app.src | grep SOURCE_SUM | cut -d= -f2) + # Download sources from the upstream + wget -nv -O source.tar.gz $src_url + # Vérifie la somme de contrôle de la source téléchargée. + echo "$src_checksum source.tar.gz" | md5sum -c --status || ynh_die "Corrupt source" + # Extract source into the app dir + sudo mkdir -p $final_path + sudo tar -x -f source.tar.gz -C $final_path --strip-components 1 + # Copie les fichiers additionnels ou modifiés. + if test -e "../sources/ajouts"; then + sudo cp -a ../sources/ajouts/. "$final_path" + fi +} + +#================================================= +#================================================= +# FUTUR YNH HELPERS +#================================================= +# Importer ce fichier de fonction avant celui des helpers officiel +# Ainsi, les officiels prendront le pas sur ceux-ci le cas échéant +#================================================= + +# Manage a fail of the script +# +# Print a warning to inform that the script was failed +# Execute the ynh_clean_setup function if used in the app script +# +# usage of ynh_clean_setup function +# This function provide a way to clean some residual of installation that not managed by remove script. +# To use it, simply add in your script: +# ynh_clean_setup () { +# instructions... +# } +# This function is optionnal. +# +# Usage: ynh_exit_properly is used only by the helper ynh_check_error. +# You must not use it directly. +ynh_exit_properly () { + exit_code=$? + if [ "$exit_code" -eq 0 ]; then + exit 0 # Exit without error if the script ended correctly + fi + + trap '' EXIT # Ignore new exit signals + set +eu # Do not exit anymore if a command fail or if a variable is empty + + echo -e "!!\n $app's script has encountered an error. Its execution was cancelled.\n!!" >&2 + + if type -t ynh_clean_setup > /dev/null; then # Check if the function exist in the app script. + ynh_clean_setup # Call the function to do specific cleaning for the app. + fi + + ynh_die # Exit with error status +} + +# Exit if an error occurs during the execution of the script. +# +# Stop immediatly the execution if an error occured or if a empty variable is used. +# The execution of the script is derivate to ynh_exit_properly function before exit. +# +# Usage: ynh_check_error +ynh_check_error () { + set -eu # Exit if a command fail, and if a variable is used unset. + trap ynh_exit_properly EXIT # Capturing exit signals on shell script +} From f88f1eb7edeca1fead6286ae251e23b7517b7445 Mon Sep 17 00:00:00 2001 From: frju365 Date: Wed, 8 Mar 2017 23:30:48 +0100 Subject: [PATCH 07/15] Delete _common.sh --- scripts/_common.sh | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 scripts/_common.sh diff --git a/scripts/_common.sh b/scripts/_common.sh deleted file mode 100644 index cfc17c4..0000000 --- a/scripts/_common.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -VERSION="1.1.6" - -JAPPIX_SOURCE_URL="https://github.com/jappix/jappix/archive/${VERSION}.tar.gz" From 3c024b243f7e1aeb1800001c1cc8d10bdc780dce Mon Sep 17 00:00:00 2001 From: frju365 Date: Wed, 8 Mar 2017 23:31:31 +0100 Subject: [PATCH 08/15] Update backup --- scripts/backup | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/backup b/scripts/backup index 4b7a6c6..f7d0cda 100644 --- a/scripts/backup +++ b/scripts/backup @@ -1,15 +1,15 @@ #!/bin/bash # causes the shell to exit if any subcommand or pipeline returns a non-zero status -set -e +set -eu # Source YNH helpers -. /usr/share/yunohost/helpers +source /usr/share/yunohost/helpers -app="jappix" +app=$YNH_APP_INSTANCE_NAME # Retrieve app settings -domain=$(sudo yunohost app setting "$app" domain) +domain=$(ynh_app_setting_get $app domain) # Save sources & data ynh_backup "/var/www/${app}" "sources" From 44055144f8a9fa646f54156bb20223120de912ff Mon Sep 17 00:00:00 2001 From: frju365 Date: Wed, 8 Mar 2017 23:32:10 +0100 Subject: [PATCH 09/15] 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 From 378de7b8457f34aecd4522c537139141bce83d09 Mon Sep 17 00:00:00 2001 From: frju365 Date: Wed, 8 Mar 2017 23:32:42 +0100 Subject: [PATCH 10/15] Update remove --- scripts/remove | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/remove b/scripts/remove index 893a4b0..da603b9 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,9 +1,12 @@ #!/bin/bash -app="jappix" +set -u +source /usr/share/yunohost/helpers + +app=$YNH_APP_INSTANCE_NAME # Retrieve arguments -domain=$(sudo yunohost app setting "$app" domain) +domain=$(ynh_app_setting_get "$app" domain) # Remove sources and configuration sudo rm -rf "/var/www/${app}" From 68239af027750d1509b27a619d51a1c3034aa600 Mon Sep 17 00:00:00 2001 From: frju365 Date: Wed, 8 Mar 2017 23:33:10 +0100 Subject: [PATCH 11/15] Update restore --- scripts/restore | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/restore b/scripts/restore index 66fa81c..bffce4b 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,12 +1,13 @@ #!/bin/bash # causes the shell to exit if any subcommand or pipeline returns a non-zero status -set -e - -app="jappix" +set -eu +source /usr/share/yunohost/helpers # Retrieve old app settings -domain=$(sudo yunohost app setting "$app" domain) +app=$YNH_APP_INSTANCE_NAME +domain=$(ynh_app_setting_get $app domain) + # Restore sources & data sudo cp -a ./sources "/var/www/${app}" From 8e126ea0fa94ed77ec1f504baeca8e56e5941a94 Mon Sep 17 00:00:00 2001 From: frju365 Date: Wed, 8 Mar 2017 23:34:00 +0100 Subject: [PATCH 12/15] Update upgrade --- scripts/upgrade | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 245ffe8..4e4e187 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,47 +1,44 @@ #!/bin/bash -set -e +set -eu +source .fonctions +source /usr/share/yunohost/helpers -source ./_common.sh +app=$YNH_APP_INSTANCE_NAME -app="jappix" - -# Retrieve arguments -domain=$(sudo yunohost app setting "$app" domain) -path=$(sudo yunohost app setting "$app" path) -name=$(sudo yunohost app setting "$app" name) -language=$(sudo yunohost app setting "$app" language) +# Récupère les infos de l'application. +domain=$(ynh_app_setting_get $app domain) +path=$(ynh_app_setting_get $app path) +name=$(ynh_app_setting_get "$app" name) +language=$(ynh_app_setting_get "$app" language) # Set default values name="${name:-YunoJappix}" language="${language:-en}" # Remove trailing "/" for next commands -path=${path%/} - -# Retrieve sources -wget -q -O jappix.tar.gz "$JAPPIX_SOURCE_URL" +CHECK_PATH +#================================================= # Copy files to the right place +#================================================= + final_path="/var/www/${app}" +ynh_app_setting_set $app final_path $final_path +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" # 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" From b07f0ee591f9f670de5a8d74e539ff2171c97108 Mon Sep 17 00:00:00 2001 From: frju365 Date: Wed, 8 Mar 2017 23:35:15 +0100 Subject: [PATCH 13/15] Update check_process --- check_process | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/check_process b/check_process index a864974..0605ce8 100644 --- a/check_process +++ b/check_process @@ -27,7 +27,8 @@ Level 2=auto Level 3=auto Level 4=1 - Level 5=auto +# Niveau 5: le test ne semble pas tout à fait savoir ce qu'est vraiment un "exit" : https://github.com/YunoHost-Apps/jappix_ynh/issues/23 + Level 5=1 Level 6=auto Level 7=auto Level 8=0 From db07f966dc9549cd7a205e9dfda85add3ed58420 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Wed, 8 Mar 2017 23:42:25 +0100 Subject: [PATCH 14/15] =?UTF-8?q?Test=20wrong=5Fuser=20d=C3=A9sactiv=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index 0605ce8..3aefe86 100644 --- a/check_process +++ b/check_process @@ -15,7 +15,7 @@ upgrade=1 backup_restore=1 multi_instance=0 - wrong_user=1 + wrong_user=0 wrong_path=1 incorrect_path=1 corrupt_source=0 From 4c1e5e806f68aab9bd45c9d786144ac8cc464103 Mon Sep 17 00:00:00 2001 From: polytan02 Date: Thu, 9 Mar 2017 22:02:01 +0000 Subject: [PATCH 15/15] Update of Readme.md Just a few corrections. --- README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index 3e59c2d..8476f1d 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,4 @@ - **YunoHost**: https://yunohost.org/ - **Shipped version:** 1.1.7 -Jappix is a full-featured XMPP web-client -with an open social platform which enables you to host your communication -platform wherever you want to. - +Jappix is a fully-featured XMPP web-client with an open social platform which enables you to host your communication platform wherever you want to.