From 86b4a7869e7bb6d48c155527b8ca31a6526f7c20 Mon Sep 17 00:00:00 2001 From: ewilly Date: Sat, 7 Jan 2017 12:41:56 +0100 Subject: [PATCH 1/4] Solving App is broken #17 --- scripts/install | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 3697179..76cd845 100644 --- a/scripts/install +++ b/scripts/install @@ -16,6 +16,17 @@ filesize=$5 admin=$6 password=$7 + +# chech if / is present at start and not at end +if [ "${path:0:1}" != "/" ] && [ ${#path} -gt 0 ]; then + # first char is not / && path not empty => add / at start + path="/$path" +fi +if [ "${path:${#path}-1}" == "/" ] && [ ${#path} -gt 1 ]; then + # last char is / && path is gretter than / + path="${path:0:${#path}-1}" +fi + # definie useful vars parent_path=/var/www final_path="$parent_path"/"$app" @@ -93,15 +104,21 @@ sudo service nginx reload || true ynh_app_setting_set "$app" unprotected_uris "/" sudo yunohost app ssowatconf +# add alias line in hosts file +echo "127.0.0.1 $domain # $app" | sudo tee -a /etc/hosts + # fill the superadmin creation form curl_path=$([ "$path" == "/" ] || echo "$path") curl https://"$domain""$curl_path"/ > /dev/null 2>&1 -curl -X POST \ +sleep 1 && curl -kX POST \ --data-urlencode creation="1" \ --data-urlencode login="$admin" \ --data-urlencode pass="$password" \ --data-urlencode confirm="$password" \ https://"$domain""$curl_path"/index.php?p=login > /dev/null 2>&1 + +# remove alias line from hosts file +sudo sed -i "/# $app/d" /etc/hosts # if app is private, remove url to SSOWat conf from skipped_uris if [ "$is_public" = "No" ]; From 45840475611caf5aa58a01102f1f270d8cdea248 Mon Sep 17 00:00:00 2001 From: ewilly Date: Sat, 7 Jan 2017 14:26:26 +0100 Subject: [PATCH 2/4] Solving App is broken #17 2 --- scripts/install | 4 ++-- scripts/restore | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 76cd845..9af6f89 100644 --- a/scripts/install +++ b/scripts/install @@ -9,7 +9,7 @@ source /usr/share/yunohost/helpers # retrieve arguments app=bozon domain=$1 -path=${2%/} +path=$2 is_public=$3 language=$4 filesize=$5 @@ -109,7 +109,7 @@ echo "127.0.0.1 $domain # $app" | sudo tee -a /etc/hosts # fill the superadmin creation form curl_path=$([ "$path" == "/" ] || echo "$path") -curl https://"$domain""$curl_path"/ > /dev/null 2>&1 +curl -k https://"$domain""$curl_path"/ > /dev/null 2>&1 sleep 1 && curl -kX POST \ --data-urlencode creation="1" \ --data-urlencode login="$admin" \ diff --git a/scripts/restore b/scripts/restore index 82c66eb..385bd23 100644 --- a/scripts/restore +++ b/scripts/restore @@ -9,6 +9,7 @@ source /usr/share/yunohost/helpers #retrieve arguments app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get "$app" domain) +path=$(ynh_app_setting_get "$app" path) # definie useful vars parent_path=/var/www From 16ef7053e6af5f93d6a0d452475c91c82a78a2a1 Mon Sep 17 00:00:00 2001 From: ewilly Date: Sun, 8 Jan 2017 12:17:57 +0100 Subject: [PATCH 3/4] Solving App is broken #17 3 * Correct restore script `ynh_package_install_from_equivs` * Change in each script `#! /bin/bash` with `#!/bin/bash` * Correct `pathluaregex` in case of a installation on root --- scripts/backup | 2 +- scripts/install | 4 ++-- scripts/remove | 2 +- scripts/restore | 5 +++-- scripts/upgrade | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/scripts/backup b/scripts/backup index eb15fff..6ea3c8e 100644 --- a/scripts/backup +++ b/scripts/backup @@ -1,4 +1,4 @@ -#! /bin/bash +#!/bin/bash # Exit on command errors and treat unset variables as an error set -eu diff --git a/scripts/install b/scripts/install index 9af6f89..0daa027 100644 --- a/scripts/install +++ b/scripts/install @@ -1,4 +1,4 @@ -#! /bin/bash +#!/bin/bash # Exit on command errors and treat unset variables as an error set -eu @@ -126,7 +126,7 @@ then ynh_app_setting_delete "$app" unprotected_uris # escape magic chars in vars (lua magic chars are ().%+-*?[^$ according to https://www.lua.org/pil/20.2.html) domainluaregex=$(echo "$domain" | sed -e 's/[]().%+*?[^$[]/\%&/g' | sed -e 's/\-/\%&/g') - pathluaregex=$(echo "$path" | sed -e 's/[]().%+*?[^$[]/\%&/g' | sed -e 's/\-/\%&/g') + pathluaregex=$([ "$path" == "/" ] || echo "$path" | sed -e 's/[]().%+*?[^$[]/\%&/g' | sed -e 's/\-/\%&/g') regexList="${domainluaregex}${pathluaregex}/index.php%?f=.+$","${domainluaregex}${pathluaregex}/index.php%?zipfolder=.+$","${domainluaregex}${pathluaregex}/private/temp/.+%.zip$","${domainluaregex}${pathluaregex}/core/js/.*$","${domainluaregex}${pathluaregex}/templates/.*$" ynh_app_setting_set "$app" unprotected_regex "$regexList" sudo yunohost app ssowatconf diff --git a/scripts/remove b/scripts/remove index 4a86735..be0c226 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,4 +1,4 @@ -#! /bin/bash +#!/bin/bash # Exit on command errors and treat unset variables as an error set -eu diff --git a/scripts/restore b/scripts/restore index 385bd23..934096b 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,4 +1,4 @@ -#! /bin/bash +#!/bin/bash # Exit on command errors and treat unset variables as an error set -eu @@ -39,7 +39,8 @@ sudo yunohost app checkurl $domain$path -a $app \ You should safely delete it before restoring this app." # add required packages -ynh_package_install_from_equivs ../conf/${app}-deps.control || ynh_die "Unable to install dependencies" +ynh_package_is_installed "php5-curl" || ynh_package_install "php5-curl" +ynh_package_is_installed "php5-gd" || ynh_package_install "php5-gd" # restore sources & data sudo cp -a ./www "$final_path" diff --git a/scripts/upgrade b/scripts/upgrade index 2b935e5..78de32e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,4 +1,4 @@ -#! /bin/bash +#!/bin/bash # Exit on command errors and treat unset variables as an error set -eu From aa877e5268b5265788f33d42f2f7486cb8575299 Mon Sep 17 00:00:00 2001 From: ewilly Date: Sun, 8 Jan 2017 14:02:58 +0100 Subject: [PATCH 4/4] Solving App is broken #17 4 * Adding a `\` at the end of alias --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 8031125..48c1c67 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,6 +1,6 @@ location YNH_EXAMPLE_PATH { # Path to source - alias YNH_EXAMPLE_ALIAS ; + alias YNH_EXAMPLE_ALIAS/; if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; }