From 03ba0348c253f4cec706509c66b996f142e94ede Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Sat, 26 Jan 2019 15:03:05 +0100 Subject: [PATCH 1/9] Add infos --- scripts/_common.sh | 16 ++++++++++++++++ scripts/change_url | 8 ++++++++ scripts/experimental_helper.sh | 3 +++ scripts/install | 2 ++ scripts/remove | 2 ++ 5 files changed, 31 insertions(+) diff --git a/scripts/_common.sh b/scripts/_common.sh index b09af15..824fafa 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -34,6 +34,8 @@ create_dir() { # CONFIGURATION FILES FOR JUPYTERLAB #================================================= config_jupyterlab() { + ynh_print_info "Configuring JupyterLab..." + create_dir jupyterlab_conf_path="$config_path/jupyterhub_config.py" @@ -55,6 +57,8 @@ config_jupyterlab() { } config_jupyter_notebook() { + ynh_print_info "Configuring Jupyter Notebook..." + jupyter_notebook_conf_path="$final_path/etc/jupyter/jupyter_notebook_config.py" ynh_backup_if_checksum_is_different $jupyter_notebook_conf_path @@ -71,6 +75,8 @@ config_jupyter_notebook() { # CREATE A DEDICATED SYSTEMD CONFIG #================================================= add_systemd_config () { + ynh_print_info "Adding Jupyterlab as a service..." + sudo cp ../conf/systemd.service.default ../conf/systemd.service tempsystemdconf="../conf/systemd.service" @@ -85,6 +91,8 @@ add_systemd_config () { # REMOVE THE CONFIGURATION FILE FOR JUPYTERLAB #================================================= remove_config_jupyterlab() { + ynh_print_info "Removing the configuration file..." + ynh_secure_remove "$config_path/jupyterhub_config.py" } @@ -140,6 +148,9 @@ setup_source() { local local_src="/opt/yunohost-apps-src/${YNH_APP_ID}/${src_filename}" + ynh_print_info "Downloading anaconda files (used by JupyterLab)..." + + if test -e "$local_src" then # Use the local source file if it is present cp $local_src $src_filename @@ -151,11 +162,16 @@ setup_source() { echo "${src_sum} ${src_filename}" | ${src_sumprg} -c --status \ || ynh_die "Corrupt source" + ynh_print_info "Installing anaconda (used by JupyterLab)..." + bash $src_filename -b -p $final_path fi export "PATH=$final_path/bin/:$PATH" + ynh_print_info "Installing JupyterLab..." + + if [ "$src_id" = "arm" ] then conda install jupyterlab=$jupyterlab_version notebook nodejs -y diff --git a/scripts/change_url b/scripts/change_url index 7bb414d..7391ef5 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -80,14 +80,22 @@ nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf if [ $change_path -eq 1 ] then + ynh_print_info "Changing path..." + + # 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 domain="$old_domain" path_url="$new_path" + # Create a dedicated nginx config ynh_add_nginx_config fi # Change the domain for nginx if [ $change_domain -eq 1 ] then + ynh_print_info "Changing domain..." + # Delete file checksum for the old conf file location ynh_delete_file_checksum "$nginx_conf_path" mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf diff --git a/scripts/experimental_helper.sh b/scripts/experimental_helper.sh index 5e6a77f..7875bfe 100644 --- a/scripts/experimental_helper.sh +++ b/scripts/experimental_helper.sh @@ -11,6 +11,7 @@ # | arg: -t, --timeout= - Timeout - The maximum time to wait before ending the watching. Default : 300 seconds. # | arg: -e, --length= - Length of the error log : Default : 20 ynh_systemd_action() { + # Declare an array to define the options of this helper. declare -Ar args_array=( [n]=service_name= [a]=action= [l]=line_match= [p]=log_path= [t]=timeout= [e]=length= ) local service_name @@ -29,6 +30,8 @@ ynh_systemd_action() { local length=${length:-20} local timeout=${timeout:-300} + ynh_print_info "Waiting for a response from $service_name..." + # Start to read the log if [[ -n "${line_match:-}" ]] then diff --git a/scripts/install b/scripts/install index 042b324..1f06239 100644 --- a/scripts/install +++ b/scripts/install @@ -61,6 +61,8 @@ ynh_app_setting_set $app enable_terminal $enable_terminal # FIND AND OPEN PORTS #================================================= +ynh_print_info "Getting ports..." + # Find free ports port=$(ynh_find_port 8080) port_hub=$(ynh_find_port $(($port + 1))) diff --git a/scripts/remove b/scripts/remove index 54f70d1..8182905 100644 --- a/scripts/remove +++ b/scripts/remove @@ -54,6 +54,8 @@ remove_config_jupyterlab # REMOVE APP MAIN DIR #================================================= +ynh_print_info "Removing JupyterLab..." + ynh_secure_remove "$final_path" ynh_secure_remove "$config_path" From 5ed100256295320c03bd052811a351472057201f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Sat, 26 Jan 2019 15:04:44 +0100 Subject: [PATCH 2/9] Format files --- manifest.json | 6 +- scripts/_common.sh | 31 ++++----- scripts/change_url | 16 ++--- scripts/experimental_helper.sh | 121 ++++++++++++++++----------------- scripts/install | 8 +-- scripts/remove | 14 ++-- scripts/upgrade | 6 +- 7 files changed, 94 insertions(+), 108 deletions(-) diff --git a/manifest.json b/manifest.json index f9186d3..8c85575 100644 --- a/manifest.json +++ b/manifest.json @@ -21,7 +21,7 @@ "nginx" ], "arguments": { - "install" : [ + "install": [ { "name": "domain", "type": "domain", @@ -43,7 +43,7 @@ }, { "name": "admin", - "type": "user", + "type": "user", "ask": { "en": "Choose an admin user", "fr": "Choisissez l’administrateur" @@ -70,4 +70,4 @@ } ] } -} +} \ No newline at end of file diff --git a/scripts/_common.sh b/scripts/_common.sh index 824fafa..d6ee48c 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -74,7 +74,7 @@ config_jupyter_notebook() { #================================================= # CREATE A DEDICATED SYSTEMD CONFIG #================================================= -add_systemd_config () { +add_systemd_config() { ynh_print_info "Adding Jupyterlab as a service..." sudo cp ../conf/systemd.service.default ../conf/systemd.service @@ -139,41 +139,36 @@ setup_source() { src_format=${src_format:-tar.gz} src_format=$(echo "$src_format" | tr '[:upper:]' '[:lower:]') src_extract=${src_extract:-true} - if [ "$src_filename" = "" ] ; then + if [ "$src_filename" = "" ]; then src_filename="${src_id}.${src_format}" fi - if ! test -e "$final_path" - then + if ! test -e "$final_path"; then local local_src="/opt/yunohost-apps-src/${YNH_APP_ID}/${src_filename}" - ynh_print_info "Downloading anaconda files (used by JupyterLab)..." + ynh_print_info "Downloading anaconda files (used by JupyterLab)..." - - if test -e "$local_src" - then # Use the local source file if it is present + if test -e "$local_src"; then # Use the local source file if it is present cp $local_src $src_filename - else # If not, download the source - local out=`wget -nv -O $src_filename $src_url 2>&1` || ynh_print_err $out + else # If not, download the source + local out=$(wget -nv -O $src_filename $src_url 2>&1) || ynh_print_err $out fi # Check the control sum - echo "${src_sum} ${src_filename}" | ${src_sumprg} -c --status \ - || ynh_die "Corrupt source" + echo "${src_sum} ${src_filename}" | ${src_sumprg} -c --status || + ynh_die "Corrupt source" - ynh_print_info "Installing anaconda (used by JupyterLab)..." + ynh_print_info "Installing anaconda (used by JupyterLab)..." bash $src_filename -b -p $final_path fi - + export "PATH=$final_path/bin/:$PATH" ynh_print_info "Installing JupyterLab..." - - if [ "$src_id" = "arm" ] - then + if [ "$src_id" = "arm" ]; then conda install jupyterlab=$jupyterlab_version notebook nodejs -y pip install jupyterhub jupyterhub-ldapauthenticator else @@ -181,4 +176,4 @@ setup_source() { fi npm install -g configurable-http-proxy -} \ No newline at end of file +} diff --git a/scripts/change_url b/scripts/change_url index 7391ef5..f7d221b 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -54,14 +54,12 @@ path_url="$new_path" #================================================= change_domain=0 -if [ "$old_domain" != "$new_domain" ] -then +if [ "$old_domain" != "$new_domain" ]; then change_domain=1 fi change_path=0 -if [ "$old_path" != "$new_path" ] -then +if [ "$old_path" != "$new_path" ]; then change_path=1 fi @@ -78,10 +76,9 @@ yunohost service stop jupyterlab #================================================= nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf -if [ $change_path -eq 1 ] -then +if [ $change_path -eq 1 ]; then ynh_print_info "Changing path..." - + # 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 @@ -92,11 +89,10 @@ then fi # Change the domain for nginx -if [ $change_domain -eq 1 ] -then +if [ $change_domain -eq 1 ]; then ynh_print_info "Changing domain..." - # Delete file checksum for the old conf file location + # Delete file checksum for the old conf file location 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 diff --git a/scripts/experimental_helper.sh b/scripts/experimental_helper.sh index 7875bfe..3aea7c4 100644 --- a/scripts/experimental_helper.sh +++ b/scripts/experimental_helper.sh @@ -12,81 +12,80 @@ # | arg: -e, --length= - Length of the error log : Default : 20 ynh_systemd_action() { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [n]=service_name= [a]=action= [l]=line_match= [p]=log_path= [t]=timeout= [e]=length= ) - local service_name - local action - local line_match - local length - local log_path - local timeout + # Declare an array to define the options of this helper. + declare -Ar args_array=([n]=service_name= [a]=action= [l]=line_match= [p]=log_path= [t]=timeout= [e]=length=) + local service_name + local action + local line_match + local length + local log_path + local timeout - # Manage arguments with getopts - ynh_handle_getopts_args "$@" + # Manage arguments with getopts + ynh_handle_getopts_args "$@" - local service_name="${service_name:-$app}" - local action=${action:-start} - local log_path="${log_path:-/var/log/$service_name/$service_name.log}" - local length=${length:-20} - local timeout=${timeout:-300} + local service_name="${service_name:-$app}" + local action=${action:-start} + local log_path="${log_path:-/var/log/$service_name/$service_name.log}" + local length=${length:-20} + local timeout=${timeout:-300} - ynh_print_info "Waiting for a response from $service_name..." + ynh_print_info "Waiting for a response from $service_name..." - # Start to read the log - if [[ -n "${line_match:-}" ]] - then - local templog="$(mktemp)" - # Following the starting of the app in its log - if [ "$log_path" == "systemd" ] ; then - # Read the systemd journal - journalctl -u $service_name -f -n0 > "$templog" & - else - # Read the specified log file - tail -F -n0 "$log_path" > "$templog" & + # Start to read the log + if [[ -n "${line_match:-}" ]]; then + local templog="$(mktemp)" + # Following the starting of the app in its log + if [ "$log_path" == "systemd" ]; then + # Read the systemd journal + journalctl -u $service_name -f -n0 >"$templog" & + else + # Read the specified log file + tail -F -n0 "$log_path" >"$templog" & + fi + # Get the PID of the tail command + local pid_tail=$! fi - # Get the PID of the tail command - local pid_tail=$! - fi - echo "${action^} the service $service_name" >&2 - systemctl $action $service_name \ - || ( journalctl --lines=$length -u $service_name >&2 \ - ; test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2 \ - ; false ) + echo "${action^} the service $service_name" >&2 + systemctl $action $service_name || + ( + journalctl --lines=$length -u $service_name >&2 \ + ; + test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2 \ + ; + false + ) - # Start the timeout and try to find line_match - if [[ -n "${line_match:-}" ]] - then - local i=0 - for i in $(seq 1 $timeout) - do - # Read the log until the sentence is found, that means the app finished to start. Or run until the timeout - if grep --quiet "$line_match" "$templog" - then - echo "The service $service_name has correctly started." >&2 - break - fi - echo -n "." >&2 - sleep 1 - done - if [ $i -eq $timeout ] - then - echo "The service $service_name didn't fully started before the timeout." >&2 - journalctl --lines=$length -u $service_name >&2 - test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2 - fi + # Start the timeout and try to find line_match + if [[ -n "${line_match:-}" ]]; then + local i=0 + for i in $(seq 1 $timeout); do + # Read the log until the sentence is found, that means the app finished to start. Or run until the timeout + if grep --quiet "$line_match" "$templog"; then + echo "The service $service_name has correctly started." >&2 + break + fi + echo -n "." >&2 + sleep 1 + done + if [ $i -eq $timeout ]; then + echo "The service $service_name didn't fully started before the timeout." >&2 + journalctl --lines=$length -u $service_name >&2 + test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2 + fi - echo "" - ynh_clean_check_starting - fi + echo "" + ynh_clean_check_starting + fi } # Clean temporary process and file used by ynh_check_starting # (usually used in ynh_clean_setup scripts) # # usage: ynh_clean_check_starting -ynh_clean_check_starting () { +ynh_clean_check_starting() { # Stop the execution of tail. kill -s 15 $pid_tail 2>&1 ynh_secure_remove "$templog" 2>&1 -} \ No newline at end of file +} diff --git a/scripts/install b/scripts/install index 1f06239..1a548c1 100644 --- a/scripts/install +++ b/scripts/install @@ -42,8 +42,8 @@ ynh_webpath_register $app $domain $path_url #================================================= # Check user parameter -ynh_user_exists "$admin" \ - || ynh_die "The chosen admin user does not exist." +ynh_user_exists "$admin" || + ynh_die "The chosen admin user does not exist." #================================================= # STORE SETTINGS FROM MANIFEST @@ -124,8 +124,8 @@ add_systemd_config # If app is public, add url to SSOWat conf as skipped_uris if [[ $is_public -eq 1 ]]; then - # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set "$app" unprotected_uris "/" + # unprotected_uris allows SSO credentials to be passed anyway. + ynh_app_setting_set "$app" unprotected_uris "/" fi #================================================= diff --git a/scripts/remove b/scripts/remove index 8182905..f45d177 100644 --- a/scripts/remove +++ b/scripts/remove @@ -37,8 +37,7 @@ ynh_remove_systemd_config #================================================= # Remove a service from the admin panel, added by `yunohost service add` -if yunohost service status | grep -q $app -then +if yunohost service status | grep -q $app; then echo "Remove $app service" yunohost service remove $app fi @@ -66,18 +65,15 @@ ynh_secure_remove "/var/log/$app.log" # CLOSE PORTS #================================================= -if yunohost firewall list | grep -q "\- $port$" -then +if yunohost firewall list | grep -q "\- $port$"; then echo "Close port $port" >&2 yunohost firewall disallow TCP $port 2>&1 fi -if yunohost firewall list | grep -q "\- $port_hub$" -then +if yunohost firewall list | grep -q "\- $port_hub$"; then echo "Close port $port_hub" >&2 yunohost firewall disallow TCP $port_hub 2>&1 fi -if yunohost firewall list | grep -q "\- $port_http_proxy$" -then +if yunohost firewall list | grep -q "\- $port_http_proxy$"; then echo "Close port $port_http_proxy" >&2 yunohost firewall disallow TCP $port_http_proxy 2>&1 fi @@ -92,4 +88,4 @@ ynh_remove_nginx_config # REMOVE LOGROTATE CONFIGURATION #================================================= -#ynh_remove_logrotate \ No newline at end of file +#ynh_remove_logrotate diff --git a/scripts/upgrade b/scripts/upgrade index 9dce9cb..ee7458f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -104,8 +104,8 @@ add_systemd_config # If app is public, add url to SSOWat conf as skipped_uris if [[ $is_public -eq 1 ]]; then - # See install script - ynh_app_setting_set "$app" unprotected_uris "/" + # See install script + ynh_app_setting_set "$app" unprotected_uris "/" fi #================================================= @@ -124,4 +124,4 @@ yunohost service add $app --log "systemd" # START SERVICE #================================================= -ynh_systemd_action -n $app -a restart -l "JupyterHub is now running at" -p "systemd" \ No newline at end of file +ynh_systemd_action -n $app -a restart -l "JupyterHub is now running at" -p "systemd" From 16eef49cbe161f4009d4aa51accef529070bb469 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Sat, 26 Jan 2019 15:11:20 +0100 Subject: [PATCH 3/9] Show progress while downloading install file --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index d6ee48c..cf6491a 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -152,7 +152,7 @@ setup_source() { if test -e "$local_src"; then # Use the local source file if it is present cp $local_src $src_filename else # If not, download the source - local out=$(wget -nv -O $src_filename $src_url 2>&1) || ynh_print_err $out + ynh_print_info $(wget -q --show-progress -O $src_filename $src_url) fi # Check the control sum From a269372aedfc09f5b50911f8cbfd127db72fb04c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Sat, 26 Jan 2019 15:15:53 +0100 Subject: [PATCH 4/9] Fix progress infos --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index cf6491a..7712935 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -152,7 +152,7 @@ setup_source() { if test -e "$local_src"; then # Use the local source file if it is present cp $local_src $src_filename else # If not, download the source - ynh_print_info $(wget -q --show-progress -O $src_filename $src_url) + wget -q --show-progress -O $src_filename $src_url fi # Check the control sum From c2a886f821d77985f8bba1b74e7c84c9b994c2dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Sat, 26 Jan 2019 16:40:36 +0100 Subject: [PATCH 5/9] add backup and restore scripts --- check_process | 2 +- manifest.json | 2 +- scripts/backup | 64 +++++++++++++++++++++++++++++ scripts/restore | 104 ++++++++++++++++++++++++++++++++++++++++++++++++ scripts/upgrade | 2 + 5 files changed, 172 insertions(+), 2 deletions(-) create mode 100644 scripts/backup create mode 100644 scripts/restore 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 #================================================= From 41bff1ff02cd712255abb71b5f5671fa8b0dc405 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Sat, 26 Jan 2019 16:48:49 +0100 Subject: [PATCH 6/9] fix restore --- scripts/restore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/restore b/scripts/restore index e8d4af6..926d4a8 100644 --- a/scripts/restore +++ b/scripts/restore @@ -71,7 +71,7 @@ ynh_install_app_dependencies openssh-server ynh_print_info "Restoring configuration files of JupyerLab..." -ynh_backup "$config_path/jupyterhub_config.py" +ynh_restore_file "$config_path/jupyterhub_config.py" #================================================= # RESTORE THE APP MAIN DIR @@ -81,7 +81,7 @@ ynh_print_info "Restoring JupyterLab..." setup_source $architecture -ynh_backup "$final_path/etc/jupyter/jupyter_notebook_config.py" +ynh_restore_file "$final_path/etc/jupyter/jupyter_notebook_config.py" #================================================= # SPECIFIC RESTORATION From 38f2e6b6c35648552111a10e14364a8dd07554b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Sat, 26 Jan 2019 17:07:08 +0100 Subject: [PATCH 7/9] create config folder --- scripts/restore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/restore b/scripts/restore index 926d4a8..76db7db 100644 --- a/scripts/restore +++ b/scripts/restore @@ -71,6 +71,8 @@ ynh_install_app_dependencies openssh-server ynh_print_info "Restoring configuration files of JupyerLab..." +create_dir + ynh_restore_file "$config_path/jupyterhub_config.py" #================================================= From 4b4c6b053c57b39d49ce2ef6e28bbb660d4c4693 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Sat, 26 Jan 2019 17:22:57 +0100 Subject: [PATCH 8/9] fix variable name --- scripts/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index 76db7db..adccb26 100644 --- a/scripts/restore +++ b/scripts/restore @@ -81,7 +81,7 @@ ynh_restore_file "$config_path/jupyterhub_config.py" ynh_print_info "Restoring JupyterLab..." -setup_source $architecture +setup_source $miniconda_architecture ynh_restore_file "$final_path/etc/jupyter/jupyter_notebook_config.py" From 1801e52066ba9b2a3a470771dd2e42336c779dca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Sun, 27 Jan 2019 01:40:26 +0100 Subject: [PATCH 9/9] Ultimate fix for the restore script --- scripts/restore | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/restore b/scripts/restore index adccb26..e2048de 100644 --- a/scripts/restore +++ b/scripts/restore @@ -15,15 +15,17 @@ 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 + cp ../settings/scripts/experimental_helper.sh ./experimental_helper.sh mkdir ./upgrade.d mkdir ../conf - cp ../settings/scripts/upgrade.d/*.sh ./upgrade.d/*.sh + cp ../settings/scripts/upgrade.d/*.sh ./upgrade.d/ cp ../settings/conf/*.default ../conf/ - chmod a+rx _common.sh upgrade.d/*.sh + chmod a+rx _common.sh experimental_helper.sh upgrade.d/* fi # Load common variables and helpers source _common.sh +source experimental_helper.sh #================================================= # MANAGE SCRIPT FAILURE @@ -92,8 +94,9 @@ ynh_restore_file "$final_path/etc/jupyter/jupyter_notebook_config.py" #================================================= ynh_restore_file "/etc/systemd/system/$app.service" +systemctl enable $app.service -yunohost service add $app --log "/var/log/$app/APP.log" +yunohost service add $app --log "systemd" #================================================= # GENERIC FINALIZATION