2019-01-20 12:36:14 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
2019-08-14 00:07:10 +02:00
|
|
|
source _common.sh
|
2019-01-20 12:36:14 +01:00
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
2019-08-18 00:02:04 +02:00
|
|
|
ynh_script_progression --message="Loading installation settings..." --weight=3
|
2019-01-20 12:36:14 +01:00
|
|
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
2019-08-14 00:07:10 +02:00
|
|
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
|
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
|
|
|
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
|
|
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|
|
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
|
|
|
port_hub=$(ynh_app_setting_get --app=$app --key=port_hub)
|
|
|
|
port_http_proxy=$(ynh_app_setting_get --app=$app --key=port_http_proxy)
|
|
|
|
enable_terminal=$(ynh_app_setting_get --app=$app --key=enable_terminal)
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CHECK VERSION
|
|
|
|
#=================================================
|
2022-03-11 00:23:07 +01:00
|
|
|
ynh_script_progression --message="Checking version..."
|
2019-08-14 00:07:10 +02:00
|
|
|
|
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
|
|
|
|
2019-01-20 12:36:14 +01:00
|
|
|
#=================================================
|
|
|
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
|
|
|
#=================================================
|
2019-08-18 00:02:04 +02:00
|
|
|
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=48
|
2019-01-20 12:36:14 +01:00
|
|
|
|
2019-08-14 00:07:10 +02:00
|
|
|
# Backup the current version of the app
|
|
|
|
ynh_backup_before_upgrade
|
|
|
|
ynh_clean_setup () {
|
|
|
|
ynh_clean_check_starting
|
2022-03-11 00:23:07 +01:00
|
|
|
# Restore it if the upgrade fails
|
2019-08-14 00:07:10 +02:00
|
|
|
ynh_restore_upgradebackup
|
|
|
|
}
|
2019-01-20 12:36:14 +01:00
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
|
|
|
#=================================================
|
2019-08-14 00:07:10 +02:00
|
|
|
# STANDARD UPGRADE STEPS
|
|
|
|
#=================================================
|
|
|
|
# STOP SYSTEMD SERVICE
|
2019-01-20 12:36:14 +01:00
|
|
|
#=================================================
|
2020-12-20 11:52:54 +01:00
|
|
|
ynh_script_progression --message="Stopping a systemd service..." --weight=2
|
2019-01-20 12:36:14 +01:00
|
|
|
|
2019-08-14 00:07:10 +02:00
|
|
|
ynh_systemd_action --service_name=$app --action="stop"
|
2019-01-20 12:36:14 +01:00
|
|
|
|
|
|
|
#=================================================
|
2022-03-11 00:23:07 +01:00
|
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
2019-01-20 12:36:14 +01:00
|
|
|
#=================================================
|
2022-03-11 00:23:07 +01:00
|
|
|
ynh_script_progression --message="Ensuring downward compatibility..."
|
2019-01-20 12:36:14 +01:00
|
|
|
|
2022-03-11 00:23:07 +01:00
|
|
|
# If final_path doesn't exist, create it
|
|
|
|
if [ -z "$final_path" ]; then
|
|
|
|
final_path=/opt/$app
|
|
|
|
|
|
|
|
mkdir -p $final_path
|
|
|
|
|
|
|
|
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Cleaning legacy permissions
|
|
|
|
if ynh_legacy_permissions_exists; then
|
|
|
|
ynh_legacy_permissions_delete_all
|
|
|
|
|
|
|
|
ynh_app_setting_delete --app=$app --key=is_public
|
|
|
|
fi
|
2019-01-20 12:36:14 +01:00
|
|
|
|
2020-12-20 11:52:54 +01:00
|
|
|
#=================================================
|
2022-03-11 00:23:07 +01:00
|
|
|
# NGINX CONFIGURATION
|
2020-12-20 11:52:54 +01:00
|
|
|
#=================================================
|
2022-03-11 00:23:07 +01:00
|
|
|
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
|
2020-12-20 11:52:54 +01:00
|
|
|
|
2022-03-11 00:23:07 +01:00
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
2020-12-20 11:52:54 +01:00
|
|
|
|
2019-01-20 12:36:14 +01:00
|
|
|
#=================================================
|
2019-08-14 00:07:10 +02:00
|
|
|
# UPGRADE DEPENDENCIES
|
2019-01-20 12:36:14 +01:00
|
|
|
#=================================================
|
2019-08-18 00:02:04 +02:00
|
|
|
ynh_script_progression --message="Upgrading dependencies..." --weight=83
|
2019-08-14 00:07:10 +02:00
|
|
|
|
|
|
|
ynh_install_app_dependencies $pkg_dependencies
|
2020-04-27 13:22:30 +02:00
|
|
|
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
2022-03-11 00:23:07 +01:00
|
|
|
ynh_use_nodejs
|
|
|
|
$ynh_npm install -g configurable-http-proxy
|
2020-02-21 09:31:30 +01:00
|
|
|
python3 -m pip install pipenv
|
2019-01-20 12:36:14 +01:00
|
|
|
|
|
|
|
#=================================================
|
2022-03-11 00:23:07 +01:00
|
|
|
# SPECIFIC UPGRADE
|
|
|
|
#=================================================
|
|
|
|
# BUILD APP
|
2019-01-20 12:36:14 +01:00
|
|
|
#=================================================
|
|
|
|
|
2019-08-14 00:07:10 +02:00
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
|
|
then
|
2022-03-11 00:23:07 +01:00
|
|
|
ynh_script_progression --message="Building app..." --weight=160
|
2019-08-14 00:07:10 +02:00
|
|
|
|
|
|
|
pushd $final_path
|
2022-03-11 00:23:07 +01:00
|
|
|
PIPENV_VENV_IN_PROJECT="enabled" PIPENV_SKIP_LOCK=true ynh_exec_warn_less python3 -m pipenv install jupyterlab==$jupyterlab_version jupyterhub notebook jupyterhub-ldapauthenticator pyzmq
|
2019-08-14 00:07:10 +02:00
|
|
|
popd
|
|
|
|
fi
|
2019-01-20 12:36:14 +01:00
|
|
|
|
|
|
|
#=================================================
|
2022-03-11 00:23:07 +01:00
|
|
|
# UPDATE A CONFIG FILE
|
2019-01-20 12:36:14 +01:00
|
|
|
#=================================================
|
2022-03-11 00:23:07 +01:00
|
|
|
ynh_script_progression --message="Updating a configuration file..."
|
2019-01-20 12:36:14 +01:00
|
|
|
|
2020-01-25 12:54:13 +01:00
|
|
|
mkdir -p "$final_path/config"
|
|
|
|
|
2021-03-17 20:07:22 +01:00
|
|
|
path=${path_url%/}
|
2019-01-20 12:36:14 +01:00
|
|
|
|
2021-03-17 18:55:20 +01:00
|
|
|
ynh_add_config --template="../conf/jupyterhub_config.py" --destination="$final_path/config/jupyterhub_config.py"
|
2019-08-14 00:07:10 +02:00
|
|
|
|
2021-03-17 18:55:20 +01:00
|
|
|
ynh_add_config --template="../conf/jupyter_notebook_config.py" --destination="$final_path/config/jupyter_notebook_config.py"
|
2019-01-20 12:36:14 +01:00
|
|
|
|
2022-03-11 00:23:07 +01:00
|
|
|
chown -R root: $final_path/
|
|
|
|
chown -R $admin: $final_path/.venv/
|
|
|
|
|
2019-01-20 12:36:14 +01:00
|
|
|
#=================================================
|
|
|
|
# SETUP SYSTEMD
|
|
|
|
#=================================================
|
2019-08-18 00:02:04 +02:00
|
|
|
ynh_script_progression --message="Upgrading systemd configuration..."
|
2019-01-20 12:36:14 +01:00
|
|
|
|
|
|
|
# Create a dedicated systemd config
|
2019-08-14 00:07:10 +02:00
|
|
|
ynh_add_systemd_config
|
2019-01-20 12:36:14 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
2019-08-14 00:07:10 +02:00
|
|
|
#=================================================
|
2022-03-11 00:23:07 +01:00
|
|
|
# INTEGRATE SERVICE IN YUNOHOST
|
2020-12-20 11:33:16 +01:00
|
|
|
#=================================================
|
2022-03-11 00:23:07 +01:00
|
|
|
ynh_script_progression --message="Integrating service in YunoHost..."
|
2020-12-20 11:33:16 +01:00
|
|
|
|
2022-03-13 13:32:43 +01:00
|
|
|
yunohost service add $app --description="$app daemon"
|
2020-12-20 11:33:16 +01:00
|
|
|
|
2019-01-20 12:36:14 +01:00
|
|
|
#=================================================
|
2019-08-14 00:07:10 +02:00
|
|
|
# START SYSTEMD SERVICE
|
2019-01-20 12:36:14 +01:00
|
|
|
#=================================================
|
2019-08-18 00:02:04 +02:00
|
|
|
ynh_script_progression --message="Starting a systemd service..."
|
2019-01-20 12:36:14 +01:00
|
|
|
|
2022-03-11 00:23:07 +01:00
|
|
|
ynh_systemd_action --service_name=$app --action="start" --line_match="JupyterHub is now running at" --log_path="systemd"
|
2019-01-20 12:36:14 +01:00
|
|
|
|
|
|
|
#=================================================
|
2019-08-14 00:07:10 +02:00
|
|
|
# RELOAD NGINX
|
2019-01-20 12:36:14 +01:00
|
|
|
#=================================================
|
2021-01-08 22:23:01 +01:00
|
|
|
ynh_script_progression --message="Reloading NGINX web server..."
|
2019-01-20 12:36:14 +01:00
|
|
|
|
2019-08-14 00:07:10 +02:00
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
2019-01-20 12:36:14 +01:00
|
|
|
|
|
|
|
#=================================================
|
2019-08-14 00:07:10 +02:00
|
|
|
# END OF SCRIPT
|
2019-01-20 12:36:14 +01:00
|
|
|
#=================================================
|
|
|
|
|
2019-08-18 00:02:04 +02:00
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|