#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= #REMOVEME? ynh_clean_setup () { ynh_clean_check_starting } # Exit if an error occurs during the execution of the script #REMOVEME? ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= #REMOVEME? domain=$YNH_APP_ARG_DOMAIN #REMOVEME? path=$YNH_APP_ARG_PATH #REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC #REMOVEME? admin=$YNH_APP_ARG_ADMIN #REMOVEME? enable_terminal=$YNH_APP_ARG_ENABLE_TERMINAL #REMOVEME? app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= #REMOVEME? ynh_script_progression --message="Validating installation parameters..." --weight=1 #REMOVEME? install_dir=/opt/$app #REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder" # Register (book) web path #REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path #================================================= # STORE SETTINGS FROM MANIFEST #================================================= #REMOVEME? ynh_script_progression --message="Storing installation settings..." --weight=1 #REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain #REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path #REMOVEME? ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=enable_terminal --value=$enable_terminal #================================================= # STANDARD MODIFICATIONS #================================================= # FIND AND OPEN A PORT #================================================= #REMOVEME? ynh_script_progression --message="Finding an available port..." --weight=1 # Find an available port #REMOVEME? port=$(ynh_find_port --port=8080) #REMOVEME? ynh_app_setting_set --app=$app --key=port --value=$port #REMOVEME? port_hub=$(ynh_find_port --port=$(($port + 1))) #REMOVEME? ynh_app_setting_set --app=$app --key=port_hub --value=$port_hub #REMOVEME? port_http_proxy=$(ynh_find_port --port=$(($port_hub + 1))) #REMOVEME? ynh_app_setting_set --app=$app --key=port_http_proxy --value=$port_http_proxy #================================================= # INSTALL DEPENDENCIES #================================================= #REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=23 #REMOVEME? ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version ynh_use_nodejs $ynh_npm install -g configurable-http-proxy python3 -m pip install pipenv #================================================= # NGINX CONFIGURATION #================================================= ynh_script_progression --message="Configuring NGINX web server..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config #================================================= # SPECIFIC SETUP #================================================= # BUILD APP #================================================= ynh_script_progression --message="Building app..." #REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir mkdir -p "$install_dir" pushd $install_dir python3 -m venv $install_dir/venv source $install_dir/venv/bin/activate ynh_exec_warn_less pip install jupyterlab==$jupyterlab_version jupyterhub jupyter_collaboration notebook jupyterhub-ldapauthenticator pyzmq jupyterlab-language-pack-fr-FR popd #================================================= # ADD A CONFIGURATION #================================================= ynh_script_progression --message="Adding a configuration file..." mkdir -p "$install_dir/config" path=${path%/} ynh_add_config --template="../conf/jupyterhub_config.py" --destination="$install_dir/config/jupyterhub_config.py" ynh_add_config --template="../conf/jupyter_notebook_config.py" --destination="$install_dir/config/jupyter_notebook_config.py" chown -R root: $install_dir/ chown -R $admin: $install_dir/venv/ #================================================= # SETUP SYSTEMD #================================================= ynh_script_progression --message="Configuring a systemd service..." --weight=3 # Create a dedicated systemd config ynh_add_systemd_config #================================================= # GENERIC FINALIZATION #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add $app --description="$app daemon" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=3 # Start a systemd service ynh_systemd_action --service_name=$app --action="start" --line_match="JupyterHub is now running at" --log_path="systemd" #================================================= # SETUP SSOWAT #================================================= #REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=4 # Make app public if necessary #REMOVEME? if [ $is_public -eq 1 ] then #REMOVEME? ynh_permission_update --permission="main" --add="visitors" fi #================================================= # RELOAD NGINX #================================================= #REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Installation of $app completed" --last