1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/jupyterlab_ynh.git synced 2024-09-03 19:26:35 +02:00
jupyterlab_ynh/scripts/install

150 lines
4.3 KiB
Text
Raw Normal View History

2018-12-28 21:59:37 +01:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source /usr/share/yunohost/helpers
2019-01-18 20:29:56 +01:00
source ./experimental_helper.sh
2018-12-28 21:59:37 +01:00
# 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
enable_terminal=$YNH_APP_ARG_ENABLE_TERMINAL
2018-12-28 21:59:37 +01:00
#=================================================
# REGISTER DOMAIN
#=================================================
# Normalize the url path syntax
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
2018-12-30 23:38:15 +01:00
ynh_app_setting_set $app domain $domain
2018-12-28 21:59:37 +01:00
ynh_app_setting_set $app path_url $path_url
ynh_app_setting_set $app is_public $is_public
2019-01-23 22:36:38 +01:00
ynh_app_setting_set $app enable_terminal $enable_terminal
2018-12-28 21:59:37 +01:00
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN PORTS
#=================================================
2019-01-26 15:03:05 +01:00
ynh_print_info "Getting ports..."
2018-12-28 21:59:37 +01:00
# Find free ports
port=$(ynh_find_port 8080)
2019-01-19 01:18:34 +01:00
port_hub=$(ynh_find_port $(($port + 1)))
port_http_proxy=$(ynh_find_port $(($port_hub + 1)))
2018-12-28 21:59:37 +01:00
yunohost firewall allow --no-upnp TCP $port 2>&1
yunohost firewall allow --no-upnp TCP $port_hub 2>&1
2019-01-19 01:18:34 +01:00
yunohost firewall allow --no-upnp TCP $port_http_proxy 2>&1
2018-12-28 21:59:37 +01:00
ynh_app_setting_set $app port $port
ynh_app_setting_set $app port_hub $port_hub
2019-01-19 01:18:34 +01:00
ynh_app_setting_set $app port_http_proxy $port_http_proxy
2018-12-28 21:59:37 +01:00
#=================================================
# 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
#=================================================
setup_source $miniconda_architecture
2018-12-28 21:59:37 +01:00
#=================================================
# SPECIFIC SETUP
#=================================================
2018-12-30 16:00:54 +01:00
# ADD HUB EXTENSION
#=================================================
2018-12-28 21:59:37 +01:00
jupyter labextension install @jupyterlab/hub-extension
jupyter lab build
2018-12-28 21:59:37 +01:00
2018-12-30 23:28:32 +01:00
chown $admin -R $final_path/share/jupyter
2018-12-30 16:00:54 +01:00
#=================================================
# CONFIGURE JUPYTER NOTEBOOK
#=================================================
config_jupyter_notebook
#=================================================
# SETUP SYSTEMD
#=================================================
# Create a dedicated systemd config
add_systemd_config
2018-12-28 21:59:37 +01:00
#=================================================
# 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
#=================================================
2019-01-18 20:29:56 +01:00
systemctl reload nginx
2018-12-28 21:59:37 +01:00
2018-12-30 16:00:54 +01:00
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
2019-01-19 12:44:46 +01:00
yunohost service add $app --log "systemd"
2018-12-30 16:00:54 +01:00
#=================================================
# START SERVICE
#=================================================
2019-01-23 22:36:38 +01:00
ynh_systemd_action -n $app -a start -l "JupyterHub is now running at" -p "systemd"