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:
parent
0784a929b6
commit
62287a7f31
3 changed files with 28 additions and 41 deletions
|
@ -63,15 +63,15 @@ set_permission() {
|
||||||
}
|
}
|
||||||
|
|
||||||
config_pgadmin() {
|
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
|
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() {
|
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/
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,53 +16,29 @@ source ./_common.sh
|
||||||
|
|
||||||
# Retrive arguments
|
# Retrive arguments
|
||||||
old_domain=$YNH_APP_OLD_DOMAIN
|
old_domain=$YNH_APP_OLD_DOMAIN
|
||||||
old_path=$YNH_APP_OLD_PATH
|
domain=$YNH_APP_NEW_DOMAIN
|
||||||
|
path_url=$(ynh_normalize_url_path ${YNH_APP_NEW_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)
|
|
||||||
|
|
||||||
http_port=$(ynh_app_setting_get "$app" http_port)
|
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
|
# STANDARD MODIFICATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# MODIFY URL IN NGINX CONF
|
# Update nginx config
|
||||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
if [ "$old_domain" != "$domain" ]
|
||||||
|
|
||||||
# Change the path in the nginx config file
|
|
||||||
if [ $change_path -eq 1 ]
|
|
||||||
then
|
then
|
||||||
ynh_replace_string "location $old_path" "location $new_path" "$nginx_conf_path"
|
# Delete file checksum for the old conf file location
|
||||||
fi
|
ynh_delete_file_checksum "/etc/nginx/conf.d/$old_domain.d/$app.conf"
|
||||||
|
|
||||||
# Change the domain for nginx
|
mv "/etc/nginx/conf.d/$old_domain.d/$app.conf" "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
if [ $change_domain -eq 1 ]
|
|
||||||
then
|
# Store file checksum for the new config file location
|
||||||
sudo mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
ynh_store_file_checksum "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
fi
|
fi
|
||||||
|
ynh_add_nginx_config
|
||||||
|
|
||||||
# Update UWSGI 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
|
# Reload services
|
||||||
sudo systemctl reload nginx.service
|
sudo systemctl reload nginx.service
|
||||||
|
|
|
@ -192,4 +192,15 @@ ynh_app_package_version () {
|
||||||
fi
|
fi
|
||||||
version_key=$(ynh_read_manifest "$manifest_path" "version")
|
version_key=$(ynh_read_manifest "$manifest_path" "version")
|
||||||
echo "${version_key/*~ynh/}"
|
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
|
||||||
}
|
}
|
Loading…
Reference in a new issue