From 99fe5e9a3b3cc72b9141439a21206805c7537618 Mon Sep 17 00:00:00 2001 From: Jimmy Monin Date: Tue, 5 Sep 2017 21:17:03 +0200 Subject: [PATCH] Use ynh_replace_string --- scripts/change_url | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index fecf7aa..34495e4 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -67,26 +67,26 @@ if [ $change_path -eq 1 ] then if [ "$new_path" = "/" ] && [ "$old_path" != "/" ] ; then # Replace path in several location occurrences based on different recognition patterns - sed --in-place "s@location $old_path/ {\$@location / {@" "$nginx_conf_path" + ynh_replace_string "location $old_path/ {\$" "location / {" "$nginx_conf_path" ynh_replace_string "location ~ ^$old_path" "location ~ ^" "$nginx_conf_path" ynh_replace_string "location $old_path {" "location / {" "$nginx_conf_path" ynh_replace_string "rewrite ^ $old_path" "rewrite ^ " "$nginx_conf_path" # Move #for-subdir comment at the beginning of the line (line not needed for "/" path) - sed --in-place "s/\(.*\) #for-subdir/#for-subdir \1/g" "$nginx_conf_path" + ynh_replace_string "\(.*\) #for-subdir" "#for-subdir \1" "$nginx_conf_path" elif [ "$new_path" != "/" ] && [ "$old_path" = "/" ] ; then # Move #for-subdir comment at the end of the line (line needed for "/path" path) - sed --in-place "s/#for-subdir\(.*\)/\1 #for-subdir/g" "$nginx_conf_path" + ynh_replace_string "#for-subdir\(.*\)" "\1 #for-subdir" "$nginx_conf_path" # Replace path in several location occurrences based on different recognition patterns - sed --in-place "s@location / {\$@location $new_path/ {@" "$nginx_conf_path" + ynh_replace_string "location / {\$" "location $new_path/ {" "$nginx_conf_path" ynh_replace_string "location ~ ^" "location ~ ^$new_path" "$nginx_conf_path" ynh_replace_string "location / {" "location $new_path {" "$nginx_conf_path" ynh_replace_string "rewrite ^ /" "rewrite ^ $new_path/" "$nginx_conf_path" else # Replace locations starting with old_path - # Look for every possible patterns for location (see https://nginx.org/en/docs/http/ngx_http_core_module.html#location) - sed --in-place "s@location\( \(=\|~\|~\*\|\^~\)\)\? \(\^\)\?$old_path@location\1 \3$new_path@" "$nginx_conf_path" + # 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" fi