2019-01-26 16:40:36 +01:00
|
|
|
#!/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
|
2019-01-27 01:40:26 +01:00
|
|
|
cp ../settings/scripts/experimental_helper.sh ./experimental_helper.sh
|
2019-01-26 16:40:36 +01:00
|
|
|
mkdir ./upgrade.d
|
|
|
|
mkdir ../conf
|
2019-01-27 01:40:26 +01:00
|
|
|
cp ../settings/scripts/upgrade.d/*.sh ./upgrade.d/
|
2019-01-26 16:40:36 +01:00
|
|
|
cp ../settings/conf/*.default ../conf/
|
2019-01-27 01:40:26 +01:00
|
|
|
chmod a+rx _common.sh experimental_helper.sh upgrade.d/*
|
2019-01-26 16:40:36 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Load common variables and helpers
|
|
|
|
source _common.sh
|
2019-01-27 01:40:26 +01:00
|
|
|
source experimental_helper.sh
|
2019-01-26 16:40:36 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# 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..."
|
|
|
|
|
2019-01-26 17:07:08 +01:00
|
|
|
create_dir
|
|
|
|
|
2019-01-26 16:48:49 +01:00
|
|
|
ynh_restore_file "$config_path/jupyterhub_config.py"
|
2019-01-26 16:40:36 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RESTORE THE APP MAIN DIR
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_print_info "Restoring JupyterLab..."
|
|
|
|
|
2019-01-26 17:22:57 +01:00
|
|
|
setup_source $miniconda_architecture
|
2019-01-26 16:40:36 +01:00
|
|
|
|
2019-01-26 16:48:49 +01:00
|
|
|
ynh_restore_file "$final_path/etc/jupyter/jupyter_notebook_config.py"
|
2019-01-26 16:40:36 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC RESTORATION
|
|
|
|
#=================================================
|
|
|
|
# RESTORE SYSTEMD
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_restore_file "/etc/systemd/system/$app.service"
|
2019-01-27 01:40:26 +01:00
|
|
|
systemctl enable $app.service
|
2019-01-26 16:40:36 +01:00
|
|
|
|
2019-01-27 01:40:26 +01:00
|
|
|
yunohost service add $app --log "systemd"
|
2019-01-26 16:40:36 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
systemctl reload nginx
|
|
|
|
|
|
|
|
ynh_systemd_action -n $app -a start -l "JupyterHub is now running at" -p "systemd"
|