1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/wallabag2_ynh.git synced 2024-10-01 13:35:06 +02:00

Manage new domain_name parameter in change_url

This commit is contained in:
Jimmy Monin 2017-12-16 17:03:42 +01:00
parent a5c9194a7c
commit e77c42fa82

View file

@ -28,6 +28,7 @@ app=$YNH_APP_INSTANCE_NAME
db_name=$(ynh_app_setting_get "$app" db_name)
db_pwd=$(ynh_app_setting_get "$app" mysqlpwd)
db_user="$db_name"
final_path=$(ynh_app_setting_get "$app" final_path)
#=================================================
# CHECK PATHS SYNTAX
@ -76,7 +77,7 @@ then
# Move #for-subdir comment at the beginning of the line (line not needed for "/" path)
ynh_replace_string "\(.*\) #for-subdir" "#for-subdir \1" "$nginx_conf_path"
elif [ "$new_path" != "/" ] && [ "$old_path" = "/" ] ; then
elif [ "$new_path" != "/" ] && [ "$old_path" = "/" ] ; then
# Move #for-subdir comment at the end of the line (line needed for "/path" path)
ynh_replace_string "#for-subdir\(.*\)" "\1 #for-subdir" "$nginx_conf_path"
@ -87,7 +88,7 @@ then
ynh_replace_string "rewrite ^ /" "rewrite ^ $new_path/" "$nginx_conf_path"
else
# Replace locations starting with old_path
# Look for every possible patterns for location directive(see https://nginx.org/en/docs/http/ngx_http_core_module.html#location)
# Look for every possible patterns for location directive (see https://nginx.org/en/docs/http/ngx_http_core_module.html#location)
ynh_replace_string "location\( \(=\|~\|~\*\|\^~\)\)\? \(\^\)\?$old_path" "location\1 \3$new_path" "$nginx_conf_path"
# Replace path in "rewrite" directive
ynh_replace_string "rewrite ^ $old_path" "rewrite ^ $new_path" "$nginx_conf_path"
@ -113,6 +114,9 @@ fi
# Configure Wallabag instance URL
ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_user" <<< "UPDATE craue_config_setting SET value = 'https://$new_domain$new_path' WHERE name = 'wallabag_url'"
# Change domain name in parameters.yml
ynh_replace_string "domain_name: https://$old_domain$old_path" "domain_name: https://$new_domain$new_path" $final_path/app/config/parameters.yml
# If "Download images locally" option has been enabled in Internal Settings
download_images_enabled=$(ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_user" <<< "SELECT value from craue_config_setting WHERE name='download_images_enabled '" | tail -n 1)
if [ "$download_images_enabled" = "1" ] ; then