1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/garradin_ynh.git synced 2024-09-03 18:36:17 +02:00

try to debug slash for root directory in install and upgrade

This commit is contained in:
Robles Rodolphe 2020-04-09 16:00:23 +02:00
parent d689169e14
commit 7da9eb853b
3 changed files with 44 additions and 16 deletions

View file

@ -51,34 +51,46 @@ fi
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating nginx web server configuration..." --time --weight=1
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
final_path=/var/www/$app
# Change the path in the nginx config file
if [ $change_path -eq 1 ]
then
# # Make a backup of the original nginx config file if modified
# ynh_backup_if_checksum_is_different "$nginx_conf_path"
# # Replace locations starting with old_path
# # Look for every location possible patterns (see https://nginx.org/en/docs/http/ngx_http_core_module.html#location)
# ynh_replace_string "location\( \(=\|~\|~\*\|\^~\)\)\? $old_path" "location\1 $new_path" "$nginx_conf_path"
# # Replace path in "return" directives
# ynh_replace_string "return \([[:digit:]]\{3\}\) $old_path" "return \1 $new_path" "$nginx_conf_path"
# # Calculate and store the nginx config file checksum
# ynh_store_file_checksum "$nginx_conf_path"
# # ynh_replace_string
# Make a backup of the original nginx config file if modified
ynh_backup_if_checksum_is_different "$nginx_conf_path"
# Replace locations starting with old_path
# Look for every location possible patterns (see https://nginx.org/en/docs/http/ngx_http_core_module.html#location)
ynh_replace_string "location\( \(=\|~\|~\*\|\^~\)\)\? $old_path" "location\1 $new_path" "$nginx_conf_path"
# Replace path in "return" directives
ynh_replace_string "return \([[:digit:]]\{3\}\) $old_path" "return \1 $new_path" "$nginx_conf_path"
# Calculate and store the nginx config file checksum
ynh_store_file_checksum "$nginx_conf_path"
# ynh_replace_string
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for nginx helper
domain="$old_domain"
path_url="$new_path"
# Create a dedicated nginx config
ynh_add_nginx_config
elif [ "$new_path" == "/" ]
then
ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path';" --target_file="$final_path/config.local.php"
else
ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php"
fi
fi
# Change the domain for nginx
if [ $change_domain -eq 1 ]
then
# Delete file checksum for the old conf file location
ynh_delete_file_checksum "$nginx_conf_path"
ynh_delete_file_checksum --file="$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location
ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf"
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
#=================================================
@ -86,5 +98,12 @@ fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
systemctl reload nginx
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for $app" --time --last

View file

@ -132,9 +132,14 @@ systemctl reload nginx
#=================================================
key=$(ynh_string_random --length=50)
cp -a $final_path/config.dist.php $final_path/config.local.php
ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php"
ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = '$key';" --target_file="$final_path/config.local.php"
if [ "$path_url" == "/" ]
then
ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url';" --target_file="$final_path/config.local.php"
else
ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php"
fi
# ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php"
# ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php"
# echo "const WWW_URI = '$path_url/';" >> $final_path/config.local.php

View file

@ -185,6 +185,11 @@ ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# backup bdd, squelettes directory and config.local.php
#=================================================
if [ "$new_path" == "/" ]
echo "const WWW_URI = '$path_url';" >> $final_path/config.local.php
else
echo "const WWW_URI = '$path_url/';" >> $final_path/config.local.php
fi
backup_bdd=/tmp/association.sqlite
backup_squelettes=/tmp/squelettes
@ -199,7 +204,6 @@ then
cp -a $backup_bdd $final_path/association.sqlite
fi
echo "const WWW_URI = '$path_url/';" >> $final_path/config.local.php
#cp -a $final_path/config.dist.php $final_path/config.local.php
# ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php"