diff --git a/conf/nginx.conf b/conf/nginx.conf index cbe969e..1d16616 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,4 +1,4 @@ -location PATHTOCHANGE/static/ { +location PATHTOCHANGEstatic/ { alias /opt/yunohost/ihatemoney/src/budget/static/; } location PATHTOCHANGE { diff --git a/scripts/_common.sh b/scripts/_common.sh index 8a1646a..3e6b5e1 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -41,3 +41,20 @@ fix_permissions() { sudo chown -R ihatemoney:ihatemoney $SRC_DIR sudo chown -R www-data:www-data ${SRC_DIR}/budget/static } + + +### Backported helpers (from testing) + + +# Add path +ynh_normalize_url_path () { + path_url=$1 + test -n "$path_url" || ynh_die "ynh_normalize_url_path expect a URL path as first argument and received nothing." + if [ "${path_url:0:1}" != "/" ]; then # If the first character is not a / + path_url="/$path_url" # Add / at begin of path variable + fi + if [ "${path_url:${#path_url}-1}" == "/" ] && [ ${#path_url} -gt 1 ]; then # If the last character is a / and that not the only character. + path_url="${path_url:0:${#path_url}-1}" # Delete the last character + fi + echo $path_url +} diff --git a/scripts/install b/scripts/install index ce9b2e5..3e2cfaa 100755 --- a/scripts/install +++ b/scripts/install @@ -13,6 +13,8 @@ app=ihatemoney # Source local utils source _common.sh +path=$(ynh_normalize_url_path $path) + # Database settings db_pwd=$(ynh_string_random) db_name=$app @@ -28,8 +30,6 @@ if [[ ! $? -eq 0 ]]; then ynh_die "${domain}${path} is not available" fi -# Remove trailing "/" for next commands -path=${path%/} # Configure database ynh_mysql_create_db "$db_name" "$db_user" "$db_pwd"