mirror of
https://github.com/YunoHost-Apps/dont-code_ynh.git
synced 2024-09-03 18:26:34 +02:00
Fixed wrong url for root paths
This commit is contained in:
parent
40eb21bd21
commit
d61139ad3e
5 changed files with 35 additions and 14 deletions
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"name": "Dont-Code Services",
|
"name": "Dont-code Services",
|
||||||
"id": "dont-code",
|
"id": "dont-code",
|
||||||
"packaging_format": 1,
|
"packaging_format": 1,
|
||||||
"description": {
|
"description": {
|
||||||
|
|
|
@ -19,6 +19,15 @@ MONGO_DB_LIST=(dontCodeProjects dontCodeDemoProjects dontCodeData dontCodeTestPr
|
||||||
#=================================================
|
#=================================================
|
||||||
# PERSONAL HELPERS
|
# PERSONAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
append_uri() {
|
||||||
|
local return="";
|
||||||
|
if [[ $1 == */ ]]; then
|
||||||
|
return=$1$2;
|
||||||
|
else
|
||||||
|
return=$1/$2
|
||||||
|
fi
|
||||||
|
echo "$return";
|
||||||
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# EXPERIMENTAL HELPERS
|
# EXPERIMENTAL HELPERS
|
||||||
|
|
|
@ -37,6 +37,7 @@ port_project=$(ynh_app_setting_get --app=$app --key=port_project)
|
||||||
port_data=$(ynh_app_setting_get --app=$app --key=port_data)
|
port_data=$(ynh_app_setting_get --app=$app --key=port_data)
|
||||||
html_path=$(ynh_app_setting_get --app=$app --key=html_path)
|
html_path=$(ynh_app_setting_get --app=$app --key=html_path)
|
||||||
document_path=$(ynh_app_setting_get --app=$app --key=document_path)
|
document_path=$(ynh_app_setting_get --app=$app --key=document_path)
|
||||||
|
document_url=$(ynh_app_setting_get --app=$app --key=document_url)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
|
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
|
||||||
|
@ -119,13 +120,13 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating .env configuration..."
|
ynh_script_progression --message="Updating .env configuration..."
|
||||||
|
|
||||||
document_url=https://${new_domain}${new_path}/documents
|
new_document_url=$(append_uri "https://${new_domain}${new_path}" "docs")
|
||||||
old_document_url=https://${old_domain}${old_path}/documents
|
ynh_app_setting_set --app=$app --key=document_url --value=$new_document_url
|
||||||
ynh_app_setting_set --app=$app --key=document_url --value=$document_url
|
|
||||||
|
|
||||||
ynh_backup_if_checksum_is_different --file="$final_path/.env"
|
ynh_backup_if_checksum_is_different --file="$final_path/.env"
|
||||||
ynh_replace_string --match_string="$old_document_url" --replace_string="$document_url" --target_file="$final_path/.env"
|
ynh_replace_string --match_string="$document_url" --replace_string="$new_document_url" --target_file="$final_path/.env"
|
||||||
ynh_store_file_checksum --file="$final_path/.env"
|
ynh_store_file_checksum --file="$final_path/.env"
|
||||||
|
document_url=new_document_url
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALISATION
|
# GENERIC FINALISATION
|
||||||
|
|
|
@ -219,7 +219,7 @@ chmod 750 "$html_path"
|
||||||
chmod -R o-rwx "$html_path"
|
chmod -R o-rwx "$html_path"
|
||||||
chown -R $app:www-data "$html_path"
|
chown -R $app:www-data "$html_path"
|
||||||
|
|
||||||
document_url=https://${domain}${path_url}/docs
|
document_url=$(append_uri "https://${domain}${path_url}" "docs")
|
||||||
|
|
||||||
ynh_app_setting_set --app=$app --key=document_url --value=$document_url
|
ynh_app_setting_set --app=$app --key=document_url --value=$document_url
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ port_data=$(ynh_app_setting_get --app=$app --key=port_data)
|
||||||
db_user=$(ynh_app_setting_get --app=$app --key=db_user)
|
db_user=$(ynh_app_setting_get --app=$app --key=db_user)
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
document_path=$(ynh_app_setting_get --app=$app --key=document_path)
|
document_path=$(ynh_app_setting_get --app=$app --key=document_path)
|
||||||
|
document_url=$(ynh_app_setting_get --app=$app --key=document_url)
|
||||||
html_path=$(ynh_app_setting_get --app=$app --key=html_path)
|
html_path=$(ynh_app_setting_get --app=$app --key=html_path)
|
||||||
|
|
||||||
PORT_LIST=($port_ide $port_preview $port_project $port_data)
|
PORT_LIST=($port_ide $port_preview $port_project $port_data)
|
||||||
|
@ -172,18 +173,28 @@ if [ "$document_path" != "/usr/share/nginx/html/$app/docs" ]; then
|
||||||
|
|
||||||
# Update the path in .env file
|
# Update the path in .env file
|
||||||
ynh_backup_if_checksum_is_different --file="$final_path/.env"
|
ynh_backup_if_checksum_is_different --file="$final_path/.env"
|
||||||
ynh_replace_string --match_string="$old_old_doc_path" --replace_string="$document_document_path" --target_file="$final_path/.env"
|
ynh_replace_string --match_string="$old_doc_path" --replace_string="$document_path" --target_file="$final_path/.env"
|
||||||
|
|
||||||
# Changed the document url as well
|
|
||||||
old_document_url=$document_url
|
|
||||||
document_url=https://${domain}${path_url}/docs
|
|
||||||
ynh_app_setting_set --app=$app --key=document_url --value=$document_url
|
|
||||||
|
|
||||||
ynh_replace_string --match_string="$old_document_url" --replace_string="$document_url" --target_file="$final_path/.env"
|
|
||||||
ynh_store_file_checksum --file="$final_path/.env"
|
ynh_store_file_checksum --file="$final_path/.env"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Regenerate the .env file if the document_url was incorrectly set before
|
||||||
|
correct_document_url=$(append_uri "https://${domain}${path_url}" "docs")
|
||||||
|
if [ "$correct_document_url" != "$document_url" ]; then
|
||||||
|
ynh_script_progression --message="Updading url for documents" --weight=1
|
||||||
|
old_doc_url=$document_url
|
||||||
|
document_url=$correct_document_url
|
||||||
|
ynh_app_setting_set --app=$app --key=document_url --value=$document_url
|
||||||
|
|
||||||
|
ynh_add_config --template=".env" --destination="$final_path/.env"
|
||||||
|
|
||||||
|
# FIXME: this should be handled by the core in the future
|
||||||
|
# You may need to use chmod 600 instead of 400,
|
||||||
|
# for example if the app is expected to be able to modify its own config
|
||||||
|
chmod 400 "$final_path/.env"
|
||||||
|
chown $app:$app "$final_path/.env"
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPDATE A CONFIG FILE
|
# UPDATE A CONFIG FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Add table
Reference in a new issue