From 275306926babadef79521b49c271b88b644c2057 Mon Sep 17 00:00:00 2001 From: kload Date: Sat, 23 May 2015 15:29:21 +0200 Subject: [PATCH] [fix] Allow installation and upgrade on the root of a domain --- conf/nginx.conf | 2 +- scripts/install | 7 +++++++ scripts/upgrade | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 10ace7d..ddface4 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,4 +1,4 @@ -location YNH_WWW_PATH { +location YNH_WWW_LOCATION { alias YNH_WWW_ALIAS ; if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; diff --git a/scripts/install b/scripts/install index 42793d5..6af35cd 100755 --- a/scripts/install +++ b/scripts/install @@ -13,6 +13,8 @@ if [[ ! $? -eq 0 ]]; then exit 1 fi +# Remove trailing "/" for next commands +path=${path%/} # Check that admin user is an existing account sudo yunohost user list --json | grep -q "\"username\": \"$admin_user\"" @@ -51,6 +53,11 @@ sudo chmod -R 700 $var_root # Modify Nginx configuration file and copy it to Nginx conf directory sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf +if [[ "$path" == "" ]]; then + sed -i "s@YNH_WWW_LOCATION@/@g" ../conf/nginx.conf +else + sed -i "s@YNH_WWW_LOCATION@$path@g" ../conf/nginx.conf +fi nginxconf=/etc/nginx/conf.d/$domain.d/jirafeau.conf sudo cp ../conf/nginx.conf $nginxconf sudo chown root: $nginxconf diff --git a/scripts/upgrade b/scripts/upgrade index 6873886..39b98c1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -33,6 +33,11 @@ sudo chown -R www-data:root $var_root sudo chmod -R 700 $var_root # Modify Nginx configuration file and copy it to Nginx conf directory +if [[ "$path" == "" ]]; then + sed -i "s@YNH_WWW_LOCATION@/@g" ../conf/nginx.conf +else + sed -i "s@YNH_WWW_LOCATION@$path@g" ../conf/nginx.conf +fi sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf nginxconf=/etc/nginx/conf.d/$domain.d/jirafeau.conf