diff --git a/scripts/_common.sh b/scripts/_common.sh index da0b085..8944eb8 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -9,7 +9,7 @@ pkg_dependencies="python3-dev python3-pip libffi-dev libzmq3-dev" nodejs_version="14" -jupyterlab_version="3.0.10" +jupyterlab_version="3.0.11" #================================================= # PERSONAL HELPERS diff --git a/scripts/change_url b/scripts/change_url index 0ab8719..4d89301 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -33,6 +33,23 @@ port_hub=$(ynh_app_setting_get --app=$app --key=port_hub) port_http_proxy=$(ynh_app_setting_get --app=$app --key=port_http_proxy) admin=$(ynh_app_setting_get --app=$app --key=admin) +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1 + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. + ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" + + # Restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED #================================================= @@ -93,21 +110,23 @@ fi # CONFIGURE JUPYTERLAB #================================================= -ynh_backup_if_checksum_is_different --file="$final_path/config/jupyterhub_config.py" +#ynh_backup_if_checksum_is_different --file="$final_path/config/jupyterhub_config.py" domain=$new_domain -path_url=$new_path +path_url=${new_path%/} -cp -f ../conf/jupyterhub_config.py $final_path/config/jupyterhub_config.py -ynh_replace_string --match_string="__URL__" --replace_string="https://$domain" --target_file="$final_path/config/jupyterhub_config.py" -ynh_replace_string --match_string="__PATH__" --replace_string="${path_url%/}" --target_file="$final_path/config/jupyterhub_config.py" -ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/config/jupyterhub_config.py" -ynh_replace_string --match_string="__PORT_HUB__" --replace_string="$port_hub" --target_file="$final_path/config/jupyterhub_config.py" -ynh_replace_string --match_string="__PORT_HTTP_PROXY__" --replace_string="$port_http_proxy" --target_file="$final_path/config/jupyterhub_config.py" -ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="$final_path/config/jupyterhub_config.py" -ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$final_path/config/jupyterhub_config.py" +# cp -f ../conf/jupyterhub_config.py $final_path/config/jupyterhub_config.py +# ynh_replace_string --match_string="__URL__" --replace_string="https://$domain" --target_file="$final_path/config/jupyterhub_config.py" +# ynh_replace_string --match_string="__PATH__" --replace_string="${path_url%/}" --target_file="$final_path/config/jupyterhub_config.py" +# ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/config/jupyterhub_config.py" +# ynh_replace_string --match_string="__PORT_HUB__" --replace_string="$port_hub" --target_file="$final_path/config/jupyterhub_config.py" +# ynh_replace_string --match_string="__PORT_HTTP_PROXY__" --replace_string="$port_http_proxy" --target_file="$final_path/config/jupyterhub_config.py" +# ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="$final_path/config/jupyterhub_config.py" +# ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$final_path/config/jupyterhub_config.py" -ynh_store_file_checksum --file="$final_path/config/jupyterhub_config.py" +# ynh_store_file_checksum --file="$final_path/config/jupyterhub_config.py" + +ynh_add_config --template="../conf/jupyterhub_config.py" --destination="$final_path/config/jupyterhub_config.py" #================================================= # GENERIC FINALISATION diff --git a/scripts/install b/scripts/install index 7838a6b..217e0bb 100644 --- a/scripts/install +++ b/scripts/install @@ -135,28 +135,32 @@ ynh_add_systemd_config mkdir -p "$final_path/config" # JupyterHub configuration -cp -f ../conf/jupyterhub_config.py $final_path/config/jupyterhub_config.py +# cp -f ../conf/jupyterhub_config.py $final_path/config/jupyterhub_config.py -ynh_replace_string --match_string="__URL__" --replace_string="https://$domain" --target_file="$final_path/config/jupyterhub_config.py" -ynh_replace_string --match_string="__PATH__" --replace_string="${path_url%/}" --target_file="$final_path/config/jupyterhub_config.py" -ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/config/jupyterhub_config.py" -ynh_replace_string --match_string="__PORT_HUB__" --replace_string="$port_hub" --target_file="$final_path/config/jupyterhub_config.py" -ynh_replace_string --match_string="__PORT_HTTP_PROXY__" --replace_string="$port_http_proxy" --target_file="$final_path/config/jupyterhub_config.py" -ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="$final_path/config/jupyterhub_config.py" -ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$final_path/config/jupyterhub_config.py" +# ynh_replace_string --match_string="__URL__" --replace_string="https://$domain" --target_file="$final_path/config/jupyterhub_config.py" +# ynh_replace_string --match_string="__PATH__" --replace_string="${path_url%/}" --target_file="$final_path/config/jupyterhub_config.py" +# ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/config/jupyterhub_config.py" +# ynh_replace_string --match_string="__PORT_HUB__" --replace_string="$port_hub" --target_file="$final_path/config/jupyterhub_config.py" +# ynh_replace_string --match_string="__PORT_HTTP_PROXY__" --replace_string="$port_http_proxy" --target_file="$final_path/config/jupyterhub_config.py" +# ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="$final_path/config/jupyterhub_config.py" +# ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$final_path/config/jupyterhub_config.py" + +ynh_add_config --template="../conf/jupyterhub_config.py" --destination="$final_path/config/jupyterhub_config.py" # Jupyter notebook configuration -cp -f ../conf/jupyter_notebook_config.py $final_path/config/jupyter_notebook_config.py +# cp -f ../conf/jupyter_notebook_config.py $final_path/config/jupyter_notebook_config.py -ynh_replace_string --match_string="__ENABLE_TERMINAL__" --replace_string="$enable_terminal" --target_file="$final_path/config/jupyter_notebook_config.py" +# ynh_replace_string --match_string="__ENABLE_TERMINAL__" --replace_string="$enable_terminal" --target_file="$final_path/config/jupyter_notebook_config.py" + +ynh_add_config --template="../conf/jupyter_notebook_config.py" --destination="$final_path/config/jupyter_notebook_config.py" #================================================= # STORE THE CONFIG FILE CHECKSUM #================================================= # Calculate and store the config file checksum into the app settings -ynh_store_file_checksum --file="$final_path/config/jupyterhub_config.py" -ynh_store_file_checksum --file="$final_path/config/jupyter_notebook_config.py" +# ynh_store_file_checksum --file="$final_path/config/jupyterhub_config.py" +# ynh_store_file_checksum --file="$final_path/config/jupyter_notebook_config.py" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index 3039fde..5cb4491 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -132,29 +132,33 @@ fi # STORE THE CONFIG FILE CHECKSUM #================================================= -ynh_backup_if_checksum_is_different --file="$final_path/config/jupyterhub_config.py" +#ynh_backup_if_checksum_is_different --file="$final_path/config/jupyterhub_config.py" mkdir -p "$final_path/config" -cp -f ../conf/jupyterhub_config.py $final_path/config/jupyterhub_config.py -ynh_replace_string --match_string="__URL__" --replace_string="https://$domain" --target_file="$final_path/config/jupyterhub_config.py" -ynh_replace_string --match_string="__PATH__" --replace_string="${path_url%/}" --target_file="$final_path/config/jupyterhub_config.py" -ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/config/jupyterhub_config.py" -ynh_replace_string --match_string="__PORT_HUB__" --replace_string="$port_hub" --target_file="$final_path/config/jupyterhub_config.py" -ynh_replace_string --match_string="__PORT_HTTP_PROXY__" --replace_string="$port_http_proxy" --target_file="$final_path/config/jupyterhub_config.py" -ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="$final_path/config/jupyterhub_config.py" -ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$final_path/config/jupyterhub_config.py" +# cp -f ../conf/jupyterhub_config.py $final_path/config/jupyterhub_config.py +# ynh_replace_string --match_string="__URL__" --replace_string="https://$domain" --target_file="$final_path/config/jupyterhub_config.py" +# ynh_replace_string --match_string="__PATH__" --replace_string="${path_url%/}" --target_file="$final_path/config/jupyterhub_config.py" +# ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/config/jupyterhub_config.py" +# ynh_replace_string --match_string="__PORT_HUB__" --replace_string="$port_hub" --target_file="$final_path/config/jupyterhub_config.py" +# ynh_replace_string --match_string="__PORT_HTTP_PROXY__" --replace_string="$port_http_proxy" --target_file="$final_path/config/jupyterhub_config.py" +# ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="$final_path/config/jupyterhub_config.py" +# ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$final_path/config/jupyterhub_config.py" -# Recalculate and store the checksum of the file for the next upgrade. -ynh_store_file_checksum --file="$final_path/config/jupyterhub_config.py" +# # Recalculate and store the checksum of the file for the next upgrade. +# ynh_store_file_checksum --file="$final_path/config/jupyterhub_config.py" -ynh_backup_if_checksum_is_different --file="$final_path/config/jupyter_notebook_config.py" +ynh_add_config --template="../conf/jupyterhub_config.py" --destination="$final_path/config/jupyterhub_config.py" -cp -f ../conf/jupyter_notebook_config.py $final_path/config/jupyter_notebook_config.py +#ynh_backup_if_checksum_is_different --file="$final_path/config/jupyter_notebook_config.py" -ynh_replace_string --match_string="__ENABLE_TERMINAL__" --replace_string="$enable_terminal" --target_file="$final_path/config/jupyter_notebook_config.py" +# cp -f ../conf/jupyter_notebook_config.py $final_path/config/jupyter_notebook_config.py -ynh_store_file_checksum --file="$final_path/config/jupyter_notebook_config.py" +# ynh_replace_string --match_string="__ENABLE_TERMINAL__" --replace_string="$enable_terminal" --target_file="$final_path/config/jupyter_notebook_config.py" + +# ynh_store_file_checksum --file="$final_path/config/jupyter_notebook_config.py" + +ynh_add_config --template="../conf/jupyter_notebook_config.py" --destination="$final_path/config/jupyter_notebook_config.py" #================================================= # SETUP SYSTEMD