diff --git a/check_process b/check_process index ad9586a..5ebabc5 100644 --- a/check_process +++ b/check_process @@ -16,7 +16,7 @@ setup_private=1 setup_public=1 upgrade=1 - backup_restore=0 + backup_restore=1 multi_instance=1 incorrect_path=1 port_already_use=1 diff --git a/manifest.json b/manifest.json index 8c85575..1a049fc 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "name": "JupyterLab", "id": "jupyterlab", "packaging_format": 1, - "version": "0.35.4~ynh2", + "version": "0.35.4~ynh3", "description": { "en": "JupyterLab for Yunohost, an extensible environment for interactive and reproducible computing (notebook, terminal, text editor, file browser, rich outputs, etc.)", "fr": "JupyterLab pour YunoHost, un environnement informatique extensible, interactif et reproductible (bloc-notes, terminal, éditeur de texte, explorateur de fichiers, texte enrichi, etc.)" diff --git a/scripts/backup b/scripts/backup new file mode 100644 index 0000000..41c96f8 --- /dev/null +++ b/scripts/backup @@ -0,0 +1,64 @@ +#!/bin/bash + +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +# Source YunoHost helpers +source /usr/share/yunohost/helpers + +# Load common variables and helpers +source ../settings/scripts/_common.sh + +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +ynh_clean_setup() { + + true +} + +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# LOAD SETTINGS +#================================================= + +# Copy NGINX configuration +domain=$(ynh_app_setting_get "$app" domain) + +#================================================= +# STANDARD BACKUP STEPS +#================================================= +# BACKUP THE NGINX CONFIGURATION +#================================================= + +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# BACKUP JUPYTERLAB +#================================================= + +ynh_print_info "Backuping of JupyterLab..." + +ynh_backup "$final_path/jupyterhub.sqlite" + +#================================================= +# BACKUP CONF FILES +#================================================= + +ynh_print_info "Backuping configuration files of JupyterLab..." + +ynh_backup "$config_path/jupyterhub_config.py" +ynh_backup "$final_path/etc/jupyter/jupyter_notebook_config.py" + +#================================================= +# BACKUP SYSTEMD +#================================================= + +ynh_backup "/etc/systemd/system/$app.service" + diff --git a/scripts/restore b/scripts/restore new file mode 100644 index 0000000..e8d4af6 --- /dev/null +++ b/scripts/restore @@ -0,0 +1,104 @@ +#!/bin/bash + +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +# Source YunoHost helpers +source /usr/share/yunohost/helpers + +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +if [ ! -e _common.sh ]; then + # Get the _common.sh file if it's not in the current directory + cp ../settings/scripts/_common.sh ./_common.sh + mkdir ./upgrade.d + mkdir ../conf + cp ../settings/scripts/upgrade.d/*.sh ./upgrade.d/*.sh + cp ../settings/conf/*.default ../conf/ + chmod a+rx _common.sh upgrade.d/*.sh +fi + +# Load common variables and helpers +source _common.sh + +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +ynh_clean_setup() { + + true +} + +#================================================= +# LOAD SETTINGS +#================================================= + +# Copy NGINX configuration +domain=$(ynh_app_setting_get "$app" domain) +path_url=$(ynh_app_setting_get "$app" path_url) + +#================================================= +# CHECK IF THE APP CAN BE RESTORED +#================================================= + +ynh_webpath_available $domain $path_url || + ynh_die "Path not available: ${domain}${path_url}" +test ! -d $final_path || + ynh_die "There is already a directory: $final_path " + +#================================================= +# STANDARD RESTORATION STEPS +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= + +ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# REINSTALL DEPENDENCIES +#================================================= + +ynh_install_app_dependencies openssh-server + +#================================================= +# RESTORE CONF FILES +#================================================= + +ynh_print_info "Restoring configuration files of JupyerLab..." + +ynh_backup "$config_path/jupyterhub_config.py" + +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= + +ynh_print_info "Restoring JupyterLab..." + +setup_source $architecture + +ynh_backup "$final_path/etc/jupyter/jupyter_notebook_config.py" + +#================================================= +# SPECIFIC RESTORATION +#================================================= +# RESTORE SYSTEMD +#================================================= + +ynh_restore_file "/etc/systemd/system/$app.service" + +yunohost service add $app --log "/var/log/$app/APP.log" + +#================================================= +# GENERIC FINALIZATION +#================================================= +# RELOAD NGINX +#================================================= + +systemctl reload nginx + +ynh_systemd_action -n $app -a start -l "JupyterHub is now running at" -p "systemd" diff --git a/scripts/upgrade b/scripts/upgrade index ee7458f..0a4c80f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -82,6 +82,8 @@ setup_source $miniconda_architecture jupyter labextension install @jupyterlab/hub-extension jupyter lab build +jupyterhub upgrade-db + chown $admin -R $final_path/share/jupyter #=================================================