diff --git a/conf/nginx.conf b/conf/nginx.conf index 6b94a65..0e3e9d8 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 ; @@ -21,7 +21,7 @@ location YNH_WWW_PATH { } # Secure DokuWiki - location ~ ^YNH_WWW_PATH/(data|conf|bin|inc)/ { + location ~ ^YNH_WWW_PATH(data|conf|bin|inc)/ { deny all; } diff --git a/scripts/install b/scripts/install index 252098c..6f2d906 100755 --- a/scripts/install +++ b/scripts/install @@ -16,6 +16,20 @@ if [[ ! $? -eq 0 ]]; then exit 1 fi +# Path need a trailing slash, and location does not. +# See conf/nginx.conf usage +location=$path +if [[ ! $path == */ ]]; then + # no trailing slash, so add it + path=$path/ +fi +if [[ ! "$location" == "/" ]]; then + # remove possible trailing slash + location=${location%/} +fi + + + # Modify dokuwiki conf sed -i "s@YNH_ADMIN_USER@$admin@g" ../conf/$APP.php @@ -36,6 +50,7 @@ sudo chown -R www-data:root $final_path/{conf,data,data/attic,data/cache,data/in sudo chmod -R 700 $final_path/{conf,data,data/attic,data/cache,data/index,data/locks,data/media*,data/meta,data/pages,data/tmp,lib/plugins} # Modify Nginx configuration file and copy it to Nginx conf directory +sed -i "s@YNH_WWW_LOCATION@$location@g" ../conf/nginx.conf sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/dokuwiki.conf diff --git a/scripts/upgrade b/scripts/upgrade index ab9b3ee..f680a83 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -8,12 +8,22 @@ is_public=$(sudo yunohost app setting dokuwiki is_public) # admin default value, if not set if [ -z "$admin" ]; then - admin=$(sudo yunohost user list | grep 'username' -m1 | awk '{print $2}') - sudo yunohost app setting dokuwiki is_public -v "$is_public" + admin=$(sudo yunohost user list | grep 'username' -m1 | awk '{print $2}') + sudo yunohost app setting dokuwiki is_public -v "$is_public" fi -# Remove trailing "/" for next commands -path=${path%/} + +# Path need a trailing slash, and location does not. +# See conf/nginx.conf usage +location=$path +if [[ ! $path == */ ]]; then + # no trailing slash, so add it + path=$path/ +fi +if [[ ! "$location" == "/" ]]; then + # remove possible trailing slash + location=${location%/} +fi # Modify dokuwiki conf sed -i "s@YNH_ADMIN_USER@$admin@g" ../conf/$APP.php @@ -43,6 +53,7 @@ sudo chown -R www-data:root $final_path/{conf,data,data/attic,data/cache,data/in sudo chmod -R 700 $final_path/{conf,data,data/attic,data/cache,data/index,data/locks,data/media*,data/meta,data/pages,data/tmp,lib/plugins} # Modify Nginx configuration file and copy it to Nginx conf directory +sed -i "s@YNH_WWW_LOCATION@$location@g" ../conf/nginx.conf sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/dokuwiki.conf