1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ihatemoney_ynh.git synced 2024-09-03 19:26:15 +02:00

Normalize path

This commit is contained in:
Jocelyn Delalande 2017-06-18 17:11:10 +02:00
parent cd65e10413
commit 00243d4a5c
3 changed files with 20 additions and 3 deletions

View file

@ -1,4 +1,4 @@
location PATHTOCHANGE/static/ {
location PATHTOCHANGEstatic/ {
alias /opt/yunohost/ihatemoney/src/budget/static/;
}
location PATHTOCHANGE {

View file

@ -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
}

View file

@ -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"