2018-12-29 01:36:14 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
source /usr/share/yunohost/helpers
|
2019-01-19 12:42:36 +01:00
|
|
|
source ./experimental_helper.sh
|
2018-12-29 01:36:14 +01:00
|
|
|
|
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
|
|
|
# Import common cmd
|
|
|
|
source ./_common.sh
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RETRIEVE 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
|
|
|
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
|
|
|
|
2019-01-03 21:36:52 +01:00
|
|
|
admin=$(ynh_app_setting_get "$app" admin)
|
2018-12-29 01:36:14 +01:00
|
|
|
port=$(ynh_app_setting_get "$app" port)
|
2019-01-03 21:36:52 +01:00
|
|
|
port_hub=$(ynh_app_setting_get "$app" port_hub)
|
2019-01-19 01:18:34 +01:00
|
|
|
port_http_proxy=$(ynh_app_setting_get "$app" port_http_proxy)
|
2018-12-29 01:36:14 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CHECK PATHS SYNTAX
|
|
|
|
#=================================================
|
|
|
|
|
2019-01-22 21:11:27 +01:00
|
|
|
test -n "$old_path" || old_path="/"
|
|
|
|
test -n "$new_path" || new_path="/"
|
2018-12-29 01:36:14 +01:00
|
|
|
new_path=$(ynh_normalize_url_path $new_path)
|
|
|
|
old_path=$(ynh_normalize_url_path $old_path)
|
|
|
|
|
|
|
|
domain="$new_domain"
|
|
|
|
path_url="$new_path"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CHECK WHICH PARTS SHOULD BE CHANGED
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
change_domain=0
|
2019-01-26 15:04:44 +01:00
|
|
|
if [ "$old_domain" != "$new_domain" ]; then
|
2018-12-29 01:36:14 +01:00
|
|
|
change_domain=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
change_path=0
|
2019-01-26 15:04:44 +01:00
|
|
|
if [ "$old_path" != "$new_path" ]; then
|
2018-12-29 01:36:14 +01:00
|
|
|
change_path=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD MODIFICATIONS
|
2019-01-04 01:40:55 +01:00
|
|
|
#=================================================
|
|
|
|
# STOP SERVICE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
yunohost service stop jupyterlab
|
|
|
|
|
2018-12-29 01:36:14 +01:00
|
|
|
#=================================================
|
|
|
|
# MODIFY URL IN NGINX
|
|
|
|
#=================================================
|
|
|
|
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
|
|
|
|
2019-01-26 15:04:44 +01:00
|
|
|
if [ $change_path -eq 1 ]; then
|
2019-01-26 15:03:05 +01:00
|
|
|
ynh_print_info "Changing path..."
|
2019-01-26 15:04:44 +01:00
|
|
|
|
2019-01-26 15:03:05 +01:00
|
|
|
# Make a backup of the original nginx config file if modified
|
|
|
|
ynh_backup_if_checksum_is_different "$nginx_conf_path"
|
|
|
|
# Set global variables for nginx helper
|
2019-01-23 22:50:23 +01:00
|
|
|
domain="$old_domain"
|
|
|
|
path_url="$new_path"
|
2019-01-26 15:03:05 +01:00
|
|
|
# Create a dedicated nginx config
|
2018-12-29 01:36:14 +01:00
|
|
|
ynh_add_nginx_config
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Change the domain for nginx
|
2019-01-26 15:04:44 +01:00
|
|
|
if [ $change_domain -eq 1 ]; then
|
2019-01-26 15:03:05 +01:00
|
|
|
ynh_print_info "Changing domain..."
|
|
|
|
|
2019-01-26 15:04:44 +01:00
|
|
|
# Delete file checksum for the old conf file location
|
2018-12-29 01:36:14 +01:00
|
|
|
ynh_delete_file_checksum "$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"
|
|
|
|
fi
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CONFIGURE JUPYTERLAB
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
config_jupyterlab
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALISATION
|
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
|
|
|
|
2019-01-18 20:29:56 +01:00
|
|
|
systemctl reload nginx
|
2019-01-04 01:40:55 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# START SERVICE
|
|
|
|
#=================================================
|
|
|
|
|
2019-01-19 16:49:07 +01:00
|
|
|
ynh_systemd_action -n $app -a restart -l "JupyterHub is now running at" -p "systemd"
|