2018-12-28 21:59:37 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
|
|
|
# Load common variables and helpers
|
|
|
|
source ./_common.sh
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Retrieve arguments
|
|
|
|
domain=$YNH_APP_ARG_DOMAIN
|
|
|
|
path_url=$YNH_APP_ARG_PATH
|
|
|
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
|
|
|
admin=$YNH_APP_ARG_ADMIN
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# REGISTER DOMAIN
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Normalize the url path syntax
|
2018-12-29 11:06:34 +01:00
|
|
|
test -n "$path_url" || path_url="/"
|
2018-12-28 21:59:37 +01:00
|
|
|
path_url=$(ynh_normalize_url_path $path_url)
|
|
|
|
|
|
|
|
# This function check also the availability of this one
|
|
|
|
ynh_webpath_register $app $domain $path_url
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# REGISTER DOMAIN
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Check user parameter
|
|
|
|
ynh_user_exists "$admin" \
|
|
|
|
|| ynh_die "The chosen admin user does not exist."
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STORE SETTINGS FROM MANIFEST
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_app_setting_set $app admin $admin
|
|
|
|
ynh_app_setting_set $app path_url $path_url
|
|
|
|
ynh_app_setting_set $app is_public $is_public
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD MODIFICATIONS
|
|
|
|
#=================================================
|
|
|
|
# FIND AND OPEN PORTS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Find free ports
|
|
|
|
port=$(ynh_find_port 8080)
|
|
|
|
|
|
|
|
yunohost firewall allow --no-upnp TCP $port 2>&1
|
|
|
|
ynh_app_setting_set $app port $port
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Create a dedicated nginx config
|
|
|
|
ynh_add_nginx_config
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CONFIGURE JUPYTERLAB
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Configure jupyterlab with jupyterhub_config.py file
|
2018-12-28 23:00:17 +01:00
|
|
|
config_jupyterlab
|
2018-12-28 21:59:37 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND INSTALL JUPYTERLAB
|
|
|
|
#=================================================
|
|
|
|
|
2018-12-29 11:06:34 +01:00
|
|
|
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-$miniconda_architecture.sh
|
2018-12-28 21:59:37 +01:00
|
|
|
|
2018-12-29 11:24:56 +01:00
|
|
|
bash Miniconda3-latest-Linux-$miniconda_architecture.sh -b -p $final_path
|
2018-12-28 21:59:37 +01:00
|
|
|
|
2018-12-28 23:47:31 +01:00
|
|
|
$final_path/bin/conda install -c conda-forge jupyterhub notebook jupyterlab jupyterhub-ldapauthenticator -y
|
2018-12-28 21:59:37 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC SETUP
|
|
|
|
#=================================================
|
|
|
|
|
2018-12-28 23:47:31 +01:00
|
|
|
$final_path/bin/jupyter labextension install @jupyterlab/hub-extension
|
|
|
|
$final_path/bin/jupyter lab build
|
2018-12-28 21:59:37 +01:00
|
|
|
|
|
|
|
#TODO Add admin
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SETUP SSOWAT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# 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 "/"
|
|
|
|
fi
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALISATION
|
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
service nginx reload
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SETUP LOGROTATE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Configure logrotate
|
|
|
|
#ynh_use_logrotate "/var/log/$app"
|