1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/pgadmin_ynh.git synced 2024-09-03 19:56:38 +02:00

Refactor change-url

This commit is contained in:
Josué Tille 2018-08-02 15:59:04 +02:00
parent 0784a929b6
commit 62287a7f31
3 changed files with 28 additions and 41 deletions

View file

@ -63,15 +63,15 @@ set_permission() {
}
config_pgadmin() {
ynh_replace_string __USER__ $pgadmin_user ../conf/config_local.py
ynh_replace_string __DOMAIN__ $domain ../conf/config_local.py
cp ../conf/config_local.py $final_path/lib/python2.7/site-packages/pgadmin4/config_local.py
ynh_replace_string __USER__ $pgadmin_user $final_path/lib/python2.7/site-packages/pgadmin4/config_local.py
ynh_replace_string __DOMAIN__ $domain $final_path/lib/python2.7/site-packages/pgadmin4/config_local.py
}
config_uwsgi() {
ynh_replace_string __USER__ $pgadmin_user ../conf/pgadmin.ini
ynh_replace_string __FINALPATH__ $final_path ../conf/pgadmin.ini
ynh_replace_string __PATH__ $path_url ../conf/pgadmin.ini
cp ../conf/pgadmin.ini /etc/uwsgi/apps-enabled/
ynh_replace_string __USER__ $pgadmin_user /etc/uwsgi/apps-enabled/pgadmin.ini
ynh_replace_string __FINALPATH__ $final_path /etc/uwsgi/apps-enabled/pgadmin.ini
ynh_replace_string __PATH__ $path_url /etc/uwsgi/apps-enabled/pgadmin.ini
}

View file

@ -16,53 +16,29 @@ source ./_common.sh
# Retrive arguments
old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH
new_domain=$YNH_APP_NEW_DOMAIN
new_path=$YNH_APP_NEW_PATH
test -n "$old_path" || old_path="/"
test -n "$new_path" || new_path="/"
new_path=$(ynh_normalize_url_path $new_path)
old_path=$(ynh_normalize_url_path $old_path)
domain=$YNH_APP_NEW_DOMAIN
path_url=$(ynh_normalize_url_path ${YNH_APP_NEW_PATH:-'/'})
http_port=$(ynh_app_setting_get "$app" http_port)
# CHECK WHICH PARTS SHOULD BE CHANGED
change_domain=0
if [ "$old_domain" != "$new_domain" ]
then
change_domain=1
fi
change_path=0
if [ "$old_path" != "$new_path" ]
then
change_path=1
fi
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# MODIFY URL IN NGINX CONF
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# Change the path in the nginx config file
if [ $change_path -eq 1 ]
# Update nginx config
if [ "$old_domain" != "$domain" ]
then
ynh_replace_string "location $old_path" "location $new_path" "$nginx_conf_path"
fi
# Delete file checksum for the old conf file location
ynh_delete_file_checksum "/etc/nginx/conf.d/$old_domain.d/$app.conf"
# Change the domain for nginx
if [ $change_domain -eq 1 ]
then
sudo mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
mv "/etc/nginx/conf.d/$old_domain.d/$app.conf" "/etc/nginx/conf.d/$domain.d/$app.conf"
# Store file checksum for the new config file location
ynh_store_file_checksum "/etc/nginx/conf.d/$domain.d/$app.conf"
fi
ynh_add_nginx_config
# Update UWSGI Config
ynh_replace_string "mount = $old_path=pgAdmin4.py" "mount = $new_path=pgAdmin4.py" /etc/uwsgi/apps-enabled/pgadmin.ini
config_uwsgi
# Reload services
sudo systemctl reload nginx.service

View file

@ -192,4 +192,15 @@ ynh_app_package_version () {
fi
version_key=$(ynh_read_manifest "$manifest_path" "version")
echo "${version_key/*~ynh/}"
}
# Delete a file checksum from the app settings
#
# $app should be defined when calling this helper
#
# usage: ynh_remove_file_checksum file
# | arg: file - The file for which the checksum will be deleted
ynh_delete_file_checksum () {
local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_'
ynh_app_setting_delete $app $checksum_setting_name
}