mirror of
https://github.com/YunoHost-Apps/jupyterlab_ynh.git
synced 2024-09-03 19:26:35 +02:00
Merge pull request #8 from YunoHost-Apps/testing
Add backup and restore scripts
This commit is contained in:
commit
5627adf72a
10 changed files with 296 additions and 104 deletions
|
@ -16,7 +16,7 @@
|
||||||
setup_private=1
|
setup_private=1
|
||||||
setup_public=1
|
setup_public=1
|
||||||
upgrade=1
|
upgrade=1
|
||||||
backup_restore=0
|
backup_restore=1
|
||||||
multi_instance=1
|
multi_instance=1
|
||||||
incorrect_path=1
|
incorrect_path=1
|
||||||
port_already_use=1
|
port_already_use=1
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"name": "JupyterLab",
|
"name": "JupyterLab",
|
||||||
"id": "jupyterlab",
|
"id": "jupyterlab",
|
||||||
"packaging_format": 1,
|
"packaging_format": 1,
|
||||||
"version": "0.35.4~ynh2",
|
"version": "0.35.4~ynh3",
|
||||||
"description": {
|
"description": {
|
||||||
"en": "JupyterLab for Yunohost, an extensible environment for interactive and reproducible computing (notebook, terminal, text editor, file browser, rich outputs, etc.)",
|
"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.)"
|
"fr": "JupyterLab pour YunoHost, un environnement informatique extensible, interactif et reproductible (bloc-notes, terminal, éditeur de texte, explorateur de fichiers, texte enrichi, etc.)"
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
"nginx"
|
"nginx"
|
||||||
],
|
],
|
||||||
"arguments": {
|
"arguments": {
|
||||||
"install" : [
|
"install": [
|
||||||
{
|
{
|
||||||
"name": "domain",
|
"name": "domain",
|
||||||
"type": "domain",
|
"type": "domain",
|
||||||
|
@ -43,7 +43,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "admin",
|
"name": "admin",
|
||||||
"type": "user",
|
"type": "user",
|
||||||
"ask": {
|
"ask": {
|
||||||
"en": "Choose an admin user",
|
"en": "Choose an admin user",
|
||||||
"fr": "Choisissez l’administrateur"
|
"fr": "Choisissez l’administrateur"
|
||||||
|
@ -70,4 +70,4 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -34,6 +34,8 @@ create_dir() {
|
||||||
# CONFIGURATION FILES FOR JUPYTERLAB
|
# CONFIGURATION FILES FOR JUPYTERLAB
|
||||||
#=================================================
|
#=================================================
|
||||||
config_jupyterlab() {
|
config_jupyterlab() {
|
||||||
|
ynh_print_info "Configuring JupyterLab..."
|
||||||
|
|
||||||
create_dir
|
create_dir
|
||||||
|
|
||||||
jupyterlab_conf_path="$config_path/jupyterhub_config.py"
|
jupyterlab_conf_path="$config_path/jupyterhub_config.py"
|
||||||
|
@ -55,6 +57,8 @@ config_jupyterlab() {
|
||||||
}
|
}
|
||||||
|
|
||||||
config_jupyter_notebook() {
|
config_jupyter_notebook() {
|
||||||
|
ynh_print_info "Configuring Jupyter Notebook..."
|
||||||
|
|
||||||
jupyter_notebook_conf_path="$final_path/etc/jupyter/jupyter_notebook_config.py"
|
jupyter_notebook_conf_path="$final_path/etc/jupyter/jupyter_notebook_config.py"
|
||||||
|
|
||||||
ynh_backup_if_checksum_is_different $jupyter_notebook_conf_path
|
ynh_backup_if_checksum_is_different $jupyter_notebook_conf_path
|
||||||
|
@ -70,7 +74,9 @@ config_jupyter_notebook() {
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE A DEDICATED SYSTEMD CONFIG
|
# 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
|
sudo cp ../conf/systemd.service.default ../conf/systemd.service
|
||||||
tempsystemdconf="../conf/systemd.service"
|
tempsystemdconf="../conf/systemd.service"
|
||||||
|
|
||||||
|
@ -85,6 +91,8 @@ add_systemd_config () {
|
||||||
# REMOVE THE CONFIGURATION FILE FOR JUPYTERLAB
|
# REMOVE THE CONFIGURATION FILE FOR JUPYTERLAB
|
||||||
#=================================================
|
#=================================================
|
||||||
remove_config_jupyterlab() {
|
remove_config_jupyterlab() {
|
||||||
|
ynh_print_info "Removing the configuration file..."
|
||||||
|
|
||||||
ynh_secure_remove "$config_path/jupyterhub_config.py"
|
ynh_secure_remove "$config_path/jupyterhub_config.py"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,33 +139,36 @@ setup_source() {
|
||||||
src_format=${src_format:-tar.gz}
|
src_format=${src_format:-tar.gz}
|
||||||
src_format=$(echo "$src_format" | tr '[:upper:]' '[:lower:]')
|
src_format=$(echo "$src_format" | tr '[:upper:]' '[:lower:]')
|
||||||
src_extract=${src_extract:-true}
|
src_extract=${src_extract:-true}
|
||||||
if [ "$src_filename" = "" ] ; then
|
if [ "$src_filename" = "" ]; then
|
||||||
src_filename="${src_id}.${src_format}"
|
src_filename="${src_id}.${src_format}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! test -e "$final_path"
|
if ! test -e "$final_path"; then
|
||||||
then
|
|
||||||
|
|
||||||
local local_src="/opt/yunohost-apps-src/${YNH_APP_ID}/${src_filename}"
|
local local_src="/opt/yunohost-apps-src/${YNH_APP_ID}/${src_filename}"
|
||||||
|
|
||||||
if test -e "$local_src"
|
ynh_print_info "Downloading anaconda files (used by JupyterLab)..."
|
||||||
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
|
cp $local_src $src_filename
|
||||||
else # If not, download the source
|
else # If not, download the source
|
||||||
local out=`wget -nv -O $src_filename $src_url 2>&1` || ynh_print_err $out
|
wget -q --show-progress -O $src_filename $src_url
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check the control sum
|
# Check the control sum
|
||||||
echo "${src_sum} ${src_filename}" | ${src_sumprg} -c --status \
|
echo "${src_sum} ${src_filename}" | ${src_sumprg} -c --status ||
|
||||||
|| ynh_die "Corrupt source"
|
ynh_die "Corrupt source"
|
||||||
|
|
||||||
|
ynh_print_info "Installing anaconda (used by JupyterLab)..."
|
||||||
|
|
||||||
bash $src_filename -b -p $final_path
|
bash $src_filename -b -p $final_path
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export "PATH=$final_path/bin/:$PATH"
|
export "PATH=$final_path/bin/:$PATH"
|
||||||
|
|
||||||
if [ "$src_id" = "arm" ]
|
ynh_print_info "Installing JupyterLab..."
|
||||||
then
|
|
||||||
|
if [ "$src_id" = "arm" ]; then
|
||||||
conda install jupyterlab=$jupyterlab_version notebook nodejs -y
|
conda install jupyterlab=$jupyterlab_version notebook nodejs -y
|
||||||
pip install jupyterhub jupyterhub-ldapauthenticator
|
pip install jupyterhub jupyterhub-ldapauthenticator
|
||||||
else
|
else
|
||||||
|
@ -165,4 +176,4 @@ setup_source() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
npm install -g configurable-http-proxy
|
npm install -g configurable-http-proxy
|
||||||
}
|
}
|
||||||
|
|
64
scripts/backup
Normal file
64
scripts/backup
Normal file
|
@ -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"
|
||||||
|
|
|
@ -54,14 +54,12 @@ path_url="$new_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
change_domain=0
|
change_domain=0
|
||||||
if [ "$old_domain" != "$new_domain" ]
|
if [ "$old_domain" != "$new_domain" ]; then
|
||||||
then
|
|
||||||
change_domain=1
|
change_domain=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
change_path=0
|
change_path=0
|
||||||
if [ "$old_path" != "$new_path" ]
|
if [ "$old_path" != "$new_path" ]; then
|
||||||
then
|
|
||||||
change_path=1
|
change_path=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -78,17 +76,23 @@ yunohost service stop jupyterlab
|
||||||
#=================================================
|
#=================================================
|
||||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||||
|
|
||||||
if [ $change_path -eq 1 ]
|
if [ $change_path -eq 1 ]; then
|
||||||
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"
|
domain="$old_domain"
|
||||||
path_url="$new_path"
|
path_url="$new_path"
|
||||||
|
# Create a dedicated nginx config
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Change the domain for nginx
|
# Change the domain for nginx
|
||||||
if [ $change_domain -eq 1 ]
|
if [ $change_domain -eq 1 ]; then
|
||||||
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"
|
ynh_delete_file_checksum "$nginx_conf_path"
|
||||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||||
# Store file checksum for the new config file location
|
# Store file checksum for the new config file location
|
||||||
|
|
|
@ -11,79 +11,81 @@
|
||||||
# | arg: -t, --timeout= - Timeout - The maximum time to wait before ending the watching. Default : 300 seconds.
|
# | 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
|
# | arg: -e, --length= - Length of the error log : Default : 20
|
||||||
ynh_systemd_action() {
|
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
|
|
||||||
|
|
||||||
# Manage arguments with getopts
|
# Declare an array to define the options of this helper.
|
||||||
ynh_handle_getopts_args "$@"
|
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
|
||||||
|
|
||||||
local service_name="${service_name:-$app}"
|
# Manage arguments with getopts
|
||||||
local action=${action:-start}
|
ynh_handle_getopts_args "$@"
|
||||||
local log_path="${log_path:-/var/log/$service_name/$service_name.log}"
|
|
||||||
local length=${length:-20}
|
|
||||||
local timeout=${timeout:-300}
|
|
||||||
|
|
||||||
# Start to read the log
|
local service_name="${service_name:-$app}"
|
||||||
if [[ -n "${line_match:-}" ]]
|
local action=${action:-start}
|
||||||
then
|
local log_path="${log_path:-/var/log/$service_name/$service_name.log}"
|
||||||
local templog="$(mktemp)"
|
local length=${length:-20}
|
||||||
# Following the starting of the app in its log
|
local timeout=${timeout:-300}
|
||||||
if [ "$log_path" == "systemd" ] ; then
|
|
||||||
# Read the systemd journal
|
ynh_print_info "Waiting for a response from $service_name..."
|
||||||
journalctl -u $service_name -f -n0 > "$templog" &
|
|
||||||
else
|
# Start to read the log
|
||||||
# Read the specified log file
|
if [[ -n "${line_match:-}" ]]; then
|
||||||
tail -F -n0 "$log_path" > "$templog" &
|
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
|
fi
|
||||||
# Get the PID of the tail command
|
|
||||||
local pid_tail=$!
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "${action^} the service $service_name" >&2
|
echo "${action^} the service $service_name" >&2
|
||||||
systemctl $action $service_name \
|
systemctl $action $service_name ||
|
||||||
|| ( journalctl --lines=$length -u $service_name >&2 \
|
(
|
||||||
; test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2 \
|
journalctl --lines=$length -u $service_name >&2 \
|
||||||
; false )
|
;
|
||||||
|
test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2 \
|
||||||
|
;
|
||||||
|
false
|
||||||
|
)
|
||||||
|
|
||||||
# Start the timeout and try to find line_match
|
# Start the timeout and try to find line_match
|
||||||
if [[ -n "${line_match:-}" ]]
|
if [[ -n "${line_match:-}" ]]; then
|
||||||
then
|
local i=0
|
||||||
local i=0
|
for i in $(seq 1 $timeout); do
|
||||||
for i in $(seq 1 $timeout)
|
# Read the log until the sentence is found, that means the app finished to start. Or run until the timeout
|
||||||
do
|
if grep --quiet "$line_match" "$templog"; then
|
||||||
# Read the log until the sentence is found, that means the app finished to start. Or run until the timeout
|
echo "The service $service_name has correctly started." >&2
|
||||||
if grep --quiet "$line_match" "$templog"
|
break
|
||||||
then
|
fi
|
||||||
echo "The service $service_name has correctly started." >&2
|
echo -n "." >&2
|
||||||
break
|
sleep 1
|
||||||
fi
|
done
|
||||||
echo -n "." >&2
|
if [ $i -eq $timeout ]; then
|
||||||
sleep 1
|
echo "The service $service_name didn't fully started before the timeout." >&2
|
||||||
done
|
journalctl --lines=$length -u $service_name >&2
|
||||||
if [ $i -eq $timeout ]
|
test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2
|
||||||
then
|
fi
|
||||||
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 ""
|
echo ""
|
||||||
ynh_clean_check_starting
|
ynh_clean_check_starting
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Clean temporary process and file used by ynh_check_starting
|
# Clean temporary process and file used by ynh_check_starting
|
||||||
# (usually used in ynh_clean_setup scripts)
|
# (usually used in ynh_clean_setup scripts)
|
||||||
#
|
#
|
||||||
# usage: ynh_clean_check_starting
|
# usage: ynh_clean_check_starting
|
||||||
ynh_clean_check_starting () {
|
ynh_clean_check_starting() {
|
||||||
# Stop the execution of tail.
|
# Stop the execution of tail.
|
||||||
kill -s 15 $pid_tail 2>&1
|
kill -s 15 $pid_tail 2>&1
|
||||||
ynh_secure_remove "$templog" 2>&1
|
ynh_secure_remove "$templog" 2>&1
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,8 +42,8 @@ ynh_webpath_register $app $domain $path_url
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Check user parameter
|
# Check user parameter
|
||||||
ynh_user_exists "$admin" \
|
ynh_user_exists "$admin" ||
|
||||||
|| ynh_die "The chosen admin user does not exist."
|
ynh_die "The chosen admin user does not exist."
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE SETTINGS FROM MANIFEST
|
# STORE SETTINGS FROM MANIFEST
|
||||||
|
@ -61,6 +61,8 @@ ynh_app_setting_set $app enable_terminal $enable_terminal
|
||||||
# FIND AND OPEN PORTS
|
# FIND AND OPEN PORTS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
ynh_print_info "Getting ports..."
|
||||||
|
|
||||||
# Find free ports
|
# Find free ports
|
||||||
port=$(ynh_find_port 8080)
|
port=$(ynh_find_port 8080)
|
||||||
port_hub=$(ynh_find_port $(($port + 1)))
|
port_hub=$(ynh_find_port $(($port + 1)))
|
||||||
|
@ -122,8 +124,8 @@ add_systemd_config
|
||||||
|
|
||||||
# If app is public, add url to SSOWat conf as skipped_uris
|
# If app is public, add url to SSOWat conf as skipped_uris
|
||||||
if [[ $is_public -eq 1 ]]; then
|
if [[ $is_public -eq 1 ]]; then
|
||||||
# unprotected_uris allows SSO credentials to be passed anyway.
|
# unprotected_uris allows SSO credentials to be passed anyway.
|
||||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
ynh_app_setting_set "$app" unprotected_uris "/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -37,8 +37,7 @@ ynh_remove_systemd_config
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Remove a service from the admin panel, added by `yunohost service add`
|
# Remove a service from the admin panel, added by `yunohost service add`
|
||||||
if yunohost service status | grep -q $app
|
if yunohost service status | grep -q $app; then
|
||||||
then
|
|
||||||
echo "Remove $app service"
|
echo "Remove $app service"
|
||||||
yunohost service remove $app
|
yunohost service remove $app
|
||||||
fi
|
fi
|
||||||
|
@ -54,6 +53,8 @@ remove_config_jupyterlab
|
||||||
# REMOVE APP MAIN DIR
|
# REMOVE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
ynh_print_info "Removing JupyterLab..."
|
||||||
|
|
||||||
ynh_secure_remove "$final_path"
|
ynh_secure_remove "$final_path"
|
||||||
ynh_secure_remove "$config_path"
|
ynh_secure_remove "$config_path"
|
||||||
|
|
||||||
|
@ -64,18 +65,15 @@ ynh_secure_remove "/var/log/$app.log"
|
||||||
# CLOSE PORTS
|
# CLOSE PORTS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if yunohost firewall list | grep -q "\- $port$"
|
if yunohost firewall list | grep -q "\- $port$"; then
|
||||||
then
|
|
||||||
echo "Close port $port" >&2
|
echo "Close port $port" >&2
|
||||||
yunohost firewall disallow TCP $port 2>&1
|
yunohost firewall disallow TCP $port 2>&1
|
||||||
fi
|
fi
|
||||||
if yunohost firewall list | grep -q "\- $port_hub$"
|
if yunohost firewall list | grep -q "\- $port_hub$"; then
|
||||||
then
|
|
||||||
echo "Close port $port_hub" >&2
|
echo "Close port $port_hub" >&2
|
||||||
yunohost firewall disallow TCP $port_hub 2>&1
|
yunohost firewall disallow TCP $port_hub 2>&1
|
||||||
fi
|
fi
|
||||||
if yunohost firewall list | grep -q "\- $port_http_proxy$"
|
if yunohost firewall list | grep -q "\- $port_http_proxy$"; then
|
||||||
then
|
|
||||||
echo "Close port $port_http_proxy" >&2
|
echo "Close port $port_http_proxy" >&2
|
||||||
yunohost firewall disallow TCP $port_http_proxy 2>&1
|
yunohost firewall disallow TCP $port_http_proxy 2>&1
|
||||||
fi
|
fi
|
||||||
|
@ -90,4 +88,4 @@ ynh_remove_nginx_config
|
||||||
# REMOVE LOGROTATE CONFIGURATION
|
# REMOVE LOGROTATE CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
#ynh_remove_logrotate
|
#ynh_remove_logrotate
|
||||||
|
|
109
scripts/restore
Normal file
109
scripts/restore
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
#!/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
|
||||||
|
cp ../settings/scripts/experimental_helper.sh ./experimental_helper.sh
|
||||||
|
mkdir ./upgrade.d
|
||||||
|
mkdir ../conf
|
||||||
|
cp ../settings/scripts/upgrade.d/*.sh ./upgrade.d/
|
||||||
|
cp ../settings/conf/*.default ../conf/
|
||||||
|
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
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
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..."
|
||||||
|
|
||||||
|
create_dir
|
||||||
|
|
||||||
|
ynh_restore_file "$config_path/jupyterhub_config.py"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE THE APP MAIN DIR
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_print_info "Restoring JupyterLab..."
|
||||||
|
|
||||||
|
setup_source $miniconda_architecture
|
||||||
|
|
||||||
|
ynh_restore_file "$final_path/etc/jupyter/jupyter_notebook_config.py"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC RESTORATION
|
||||||
|
#=================================================
|
||||||
|
# RESTORE SYSTEMD
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_restore_file "/etc/systemd/system/$app.service"
|
||||||
|
systemctl enable $app.service
|
||||||
|
|
||||||
|
yunohost service add $app --log "systemd"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC FINALIZATION
|
||||||
|
#=================================================
|
||||||
|
# RELOAD NGINX
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
systemctl reload nginx
|
||||||
|
|
||||||
|
ynh_systemd_action -n $app -a start -l "JupyterHub is now running at" -p "systemd"
|
|
@ -82,6 +82,8 @@ setup_source $miniconda_architecture
|
||||||
jupyter labextension install @jupyterlab/hub-extension
|
jupyter labextension install @jupyterlab/hub-extension
|
||||||
jupyter lab build
|
jupyter lab build
|
||||||
|
|
||||||
|
jupyterhub upgrade-db
|
||||||
|
|
||||||
chown $admin -R $final_path/share/jupyter
|
chown $admin -R $final_path/share/jupyter
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -104,8 +106,8 @@ add_systemd_config
|
||||||
|
|
||||||
# If app is public, add url to SSOWat conf as skipped_uris
|
# If app is public, add url to SSOWat conf as skipped_uris
|
||||||
if [[ $is_public -eq 1 ]]; then
|
if [[ $is_public -eq 1 ]]; then
|
||||||
# See install script
|
# See install script
|
||||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
ynh_app_setting_set "$app" unprotected_uris "/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -124,4 +126,4 @@ yunohost service add $app --log "systemd"
|
||||||
# START SERVICE
|
# START SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_systemd_action -n $app -a restart -l "JupyterHub is now running at" -p "systemd"
|
ynh_systemd_action -n $app -a restart -l "JupyterHub is now running at" -p "systemd"
|
||||||
|
|
Loading…
Add table
Reference in a new issue