mirror of
https://github.com/YunoHost-Apps/jupyterlab_ynh.git
synced 2024-09-03 19:26:35 +02:00
v2
This commit is contained in:
parent
926d70bcac
commit
559bb3bd5e
9 changed files with 229 additions and 161 deletions
|
@ -1 +1 @@
|
|||
__APP__ ALL=(%__APP__.main) NOPASSWD: __FINALPATH__/.venv/bin/sudospawner
|
||||
__APP__ ALL=(%__APP__.main) NOPASSWD: __INSTALL_DIR__/.venv/bin/sudospawner
|
||||
|
|
|
@ -9,10 +9,10 @@ Environment="PATH=__NODE_PATH__:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bi
|
|||
Environment="JUPYTERHUB_SINGLEUSER_APP=jupyter_server.serverapp.ServerApp"
|
||||
User=__APP__
|
||||
Group=__APP__
|
||||
ExecStart=/usr/local/bin/pipenv run jupyterhub -f __FINALPATH__/config/jupyterhub_config.py
|
||||
ExecStart=/usr/local/bin/pipenv run jupyterhub -f __INSTALL_DIR__/config/jupyterhub_config.py
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
WorkingDirectory=__FINALPATH__
|
||||
WorkingDirectory=__INSTALL_DIR__
|
||||
|
||||
# Sandboxing options to harden security
|
||||
# Depending on specificities of your service/app, you may need to tweak these
|
||||
|
|
68
manifest.toml
Normal file
68
manifest.toml
Normal file
|
@ -0,0 +1,68 @@
|
|||
packaging_format = 2
|
||||
|
||||
id = "jupyterlab"
|
||||
name = "JupyterLab"
|
||||
description.en = "Code console environment for running Python code interactively"
|
||||
description.fr = "Console de code pour exécuter du code Python de manière interactive"
|
||||
|
||||
version = "3.1.11~ynh1"
|
||||
|
||||
maintainers = ["kay0u"]
|
||||
|
||||
[upstream]
|
||||
license = "BSD-3-Clause"
|
||||
website = "https://example.com"
|
||||
demo = "https://mybinder.org/v2/gh/jupyterlab/jupyterlab-demo/master?urlpath=lab/tree/demo"
|
||||
admindoc = "https://jupyterlab.readthedocs.io/en/stable/"
|
||||
userdoc = "https://yunohost.org/en/app_jupyterlab"
|
||||
code = "https://github.com/jupyterhub/jupyterhub"
|
||||
cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number)
|
||||
fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin.
|
||||
|
||||
[integration]
|
||||
yunohost = ">= 4.3.0"
|
||||
architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"]
|
||||
multi_instance = true
|
||||
ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials.
|
||||
sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal.
|
||||
disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ...
|
||||
ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
|
||||
ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
|
||||
|
||||
[install]
|
||||
[install.domain]
|
||||
# this is a generic question - ask strings are automatically handled by Yunohost's core
|
||||
type = "domain"
|
||||
|
||||
[install.path]
|
||||
# this is a generic question - ask strings are automatically handled by Yunohost's core
|
||||
type = "path"
|
||||
default = "/jupyterlab"
|
||||
|
||||
[install.admin]
|
||||
# this is a generic question - ask strings are automatically handled by Yunohost's core
|
||||
type = "user"
|
||||
|
||||
[install.init_main_permission]
|
||||
type = "group"
|
||||
default = "visitors"
|
||||
|
||||
[install.enable_terminal]
|
||||
ask.en = "Enable terminal in the lab?"
|
||||
ask.fr = "Activer le terminal dans le lab ?"
|
||||
type = "boolean"
|
||||
default = true
|
||||
|
||||
[install.enable_extensions]
|
||||
ask.en = "Allow users to install extensions?"
|
||||
ask.fr = "Permettre aux utilisateurs d'installer des extensions ?"
|
||||
type = "boolean"
|
||||
default = true
|
||||
|
||||
[resources]
|
||||
[resources.system_user]
|
||||
|
||||
[resources.install_dir]
|
||||
|
||||
[resources.permissions]
|
||||
main.url = "/"
|
|
@ -5,7 +5,7 @@
|
|||
#=================================================
|
||||
|
||||
# dependencies used by the app
|
||||
pkg_dependencies="python3-dev python3-pip libffi-dev libzmq3-dev"
|
||||
#REMOVEME? pkg_dependencies="python3-dev python3-pip libffi-dev libzmq3-dev"
|
||||
|
||||
nodejs_version="16"
|
||||
|
||||
|
|
|
@ -14,28 +14,28 @@ source /usr/share/yunohost/helpers
|
|||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
#REMOVEME? ynh_clean_setup () {
|
||||
true
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
#REMOVEME? ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info --message="Loading installation settings..."
|
||||
#REMOVEME? ynh_print_info --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain="$(ynh_app_setting_get --app=$app --key=domain)"
|
||||
path_url="$(ynh_app_setting_get --app=$app --key=path)"
|
||||
admin="$(ynh_app_setting_get --app=$app --key=admin)"
|
||||
final_path="$(ynh_app_setting_get --app=$app --key=final_path)"
|
||||
port="$(ynh_app_setting_get --app=$app --key=port)"
|
||||
port_hub="$(ynh_app_setting_get --app=$app --key=port_hub)"
|
||||
port_http_proxy="$(ynh_app_setting_get --app=$app --key=port_http_proxy)"
|
||||
enable_terminal="$(ynh_app_setting_get --app=$app --key=enable_terminal)"
|
||||
enable_extensions="$(ynh_app_setting_get --app=$app --key=enable_extensions)"
|
||||
#REMOVEME? domain="$(ynh_app_setting_get --app=$app --key=domain)"
|
||||
#REMOVEME? path="$(ynh_app_setting_get --app=$app --key=path)"
|
||||
#REMOVEME? admin="$(ynh_app_setting_get --app=$app --key=admin)"
|
||||
#REMOVEME? #REMOVEME? install_dir="$(ynh_app_setting_get --app=$app --key=install_dir)"
|
||||
#REMOVEME? port="$(ynh_app_setting_get --app=$app --key=port)"
|
||||
#REMOVEME? port_hub="$(ynh_app_setting_get --app=$app --key=port_hub)"
|
||||
#REMOVEME? port_http_proxy="$(ynh_app_setting_get --app=$app --key=port_http_proxy)"
|
||||
#REMOVEME? enable_terminal="$(ynh_app_setting_get --app=$app --key=enable_terminal)"
|
||||
#REMOVEME? enable_extensions="$(ynh_app_setting_get --app=$app --key=enable_extensions)"
|
||||
|
||||
#=================================================
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
|
@ -46,7 +46,7 @@ ynh_print_info --message="Declaring files to be backed up..."
|
|||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="$final_path"
|
||||
ynh_backup --src_path="$install_dir"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
|
|
102
scripts/install
102
scripts/install
|
@ -13,44 +13,44 @@ source /usr/share/yunohost/helpers
|
|||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
#REMOVEME? ynh_clean_setup () {
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
#REMOVEME? ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||
#=================================================
|
||||
|
||||
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
|
||||
enable_extensions=$YNH_APP_ARG_ENABLE_EXTENSIONS
|
||||
#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? enable_extensions=$YNH_APP_ARG_ENABLE_EXTENSIONS
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating installation parameters..." --weight=1
|
||||
#REMOVEME? ynh_script_progression --message="Validating installation parameters..." --weight=1
|
||||
|
||||
final_path=/opt/yunohost/$app
|
||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||
#REMOVEME? install_dir=/opt/yunohost/$app
|
||||
#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder"
|
||||
|
||||
# Register (book) web path
|
||||
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||
#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Storing installation settings..." --weight=1
|
||||
#REMOVEME? ynh_script_progression --message="Storing installation settings..." --weight=1
|
||||
|
||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
||||
#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
|
||||
ynh_app_setting_set --app=$app --key=enable_extensions --value=$enable_extensions
|
||||
|
||||
|
@ -59,31 +59,31 @@ ynh_app_setting_set --app=$app --key=enable_extensions --value=$enable_extension
|
|||
#=================================================
|
||||
# FIND AND OPEN A PORT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Finding an available port..." --weight=1
|
||||
#REMOVEME? ynh_script_progression --message="Finding an available port..." --weight=1
|
||||
|
||||
# Find a free port
|
||||
port=$(ynh_find_port --port=8080)
|
||||
port_hub=$(ynh_find_port --port=$(($port + 1)))
|
||||
port_http_proxy=$(ynh_find_port --port=$(($port_hub + 1)))
|
||||
#REMOVEME? port=$(ynh_find_port --port=8080)
|
||||
#REMOVEME? port_hub=$(ynh_find_port --port=$(($port + 1)))
|
||||
#REMOVEME? port_http_proxy=$(ynh_find_port --port=$(($port_hub + 1)))
|
||||
|
||||
ynh_app_setting_set --app=$app --key=port --value=$port
|
||||
ynh_app_setting_set --app=$app --key=port_hub --value=$port_hub
|
||||
ynh_app_setting_set --app=$app --key=port_http_proxy --value=$port_http_proxy
|
||||
#REMOVEME? ynh_app_setting_set --app=$app --key=port --value=$port
|
||||
#REMOVEME? ynh_app_setting_set --app=$app --key=port_hub --value=$port_hub
|
||||
#REMOVEME? ynh_app_setting_set --app=$app --key=port_http_proxy --value=$port_http_proxy
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring system user..." --weight=1
|
||||
#REMOVEME? ynh_script_progression --message="Configuring system user..." --weight=1
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create --username=$app
|
||||
#REMOVEME? ynh_system_user_create --username=$app
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing dependencies..." --weight=23
|
||||
#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=23
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||
|
||||
|
@ -96,16 +96,16 @@ npm install -g configurable-http-proxy
|
|||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..." --weight=64
|
||||
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
|
||||
|
||||
# Set permissions to app files
|
||||
mkdir -p "$final_path/.venv"
|
||||
chown -R $app:$app "$final_path"
|
||||
chmod -R g=u,g-w,o-rwx "$final_path"
|
||||
setfacl -nR -m g:$app.main:rx -m d:g:$app.main:rx "$final_path/.venv"
|
||||
setfacl -n -m g:$app.main:x "$final_path"
|
||||
mkdir -p "$install_dir/.venv"
|
||||
chown -R $app:$app "$install_dir"
|
||||
chmod -R g=u,g-w,o-rwx "$install_dir"
|
||||
setfacl -nR -m g:$app.main:rx -m d:g:$app.main:rx "$install_dir/.venv"
|
||||
setfacl -n -m g:$app.main:x "$install_dir"
|
||||
|
||||
pushd "$final_path"
|
||||
pushd "$install_dir"
|
||||
sudo -u $app PIPENV_VENV_IN_PROJECT="enabled" PIPENV_SKIP_LOCK=true python3 -m pipenv install jupyterlab==$jupyterlab_version jupyterhub notebook jupyter-server jupyterhub-ldapauthenticator pyzmq sudospawner --three 2>&1
|
||||
sudo -u $app python3 -m pipenv run jupyterhub upgrade-db 2>&1
|
||||
popd
|
||||
|
@ -134,13 +134,13 @@ ynh_add_systemd_config
|
|||
# MODIFY A CONFIG FILE
|
||||
#=================================================
|
||||
|
||||
mkdir -p "$final_path/config"
|
||||
path="${path_url%/}"
|
||||
mkdir -p "$install_dir/config"
|
||||
path="${path%/}"
|
||||
|
||||
ynh_add_config --template="jupyterhub_config.py" --destination="$final_path/config/jupyterhub_config.py"
|
||||
ynh_add_config --template="jupyter_server_config.py" --destination="$final_path/config/jupyter_server_config.py"
|
||||
ynh_add_config --template="jupyterhub_config.py" --destination="$install_dir/config/jupyterhub_config.py"
|
||||
ynh_add_config --template="jupyter_server_config.py" --destination="$install_dir/config/jupyter_server_config.py"
|
||||
ynh_add_config --template="app-sudoers" --destination="/etc/sudoers.d/$app-sudoers"
|
||||
ynh_add_config --template="sudospawner-singleuser" --destination="$final_path/.venv/bin/sudospawner-singleuser"
|
||||
ynh_add_config --template="sudospawner-singleuser" --destination="$install_dir/.venv/bin/sudospawner-singleuser"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
|
@ -149,11 +149,11 @@ ynh_add_config --template="sudospawner-singleuser" --destination="$final_path/.v
|
|||
#=================================================
|
||||
|
||||
# Set permissions to app files
|
||||
chmod 550 "$final_path/.venv/bin/sudospawner-singleuser"
|
||||
chown -R $app:$app "$final_path"
|
||||
chmod -R g=u,g-w,o-rwx "$final_path"
|
||||
setfacl -nR -m g:$app.main:rx -m d:g:$app.main:rx "$final_path/.venv"
|
||||
setfacl -n -m g:$app.main:x "$final_path"
|
||||
chmod 550 "$install_dir/.venv/bin/sudospawner-singleuser"
|
||||
chown -R $app:$app "$install_dir"
|
||||
chmod -R g=u,g-w,o-rwx "$install_dir"
|
||||
setfacl -nR -m g:$app.main:rx -m d:g:$app.main:rx "$install_dir/.venv"
|
||||
setfacl -n -m g:$app.main:x "$install_dir"
|
||||
chown root:root "/etc/sudoers.d/$app-sudoers"
|
||||
chmod 440 "/etc/sudoers.d/$app-sudoers"
|
||||
|
||||
|
@ -167,7 +167,7 @@ if [ $enable_extensions -eq 1 ]; then
|
|||
for user in $(ynh_user_list); do
|
||||
JUPYTERLAB_DIR="$(getent passwd $user | cut -d: -f6)/.local/share/$app/lab"
|
||||
node_path="$nodejs_path:$(sudo -u $user sh -c 'echo $PATH')"
|
||||
sudo -u $user env "PATH=$node_path" "$final_path/.venv/bin/jupyter" lab build --app-dir="$JUPYTERLAB_DIR"
|
||||
sudo -u $user env "PATH=$node_path" "$install_dir/.venv/bin/jupyter" lab build --app-dir="$JUPYTERLAB_DIR"
|
||||
done
|
||||
fi
|
||||
|
||||
|
@ -188,19 +188,19 @@ ynh_systemd_action --service_name=$app --action="start" --line_match="JupyterHub
|
|||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring permissions..." --weight=4
|
||||
#REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=4
|
||||
|
||||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]; then
|
||||
ynh_permission_update --permission="main" --add="visitors"
|
||||
#REMOVEME? if [ $is_public -eq 1 ]; then
|
||||
#REMOVEME? ynh_permission_update --permission="main" --add="visitors"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
|
@ -12,19 +12,19 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain="$(ynh_app_setting_get --app=$app --key=domain)"
|
||||
path_url="$(ynh_app_setting_get --app=$app --key=path)"
|
||||
admin="$(ynh_app_setting_get --app=$app --key=admin)"
|
||||
final_path="$(ynh_app_setting_get --app=$app --key=final_path)"
|
||||
port="$(ynh_app_setting_get --app=$app --key=port)"
|
||||
port_hub="$(ynh_app_setting_get --app=$app --key=port_hub)"
|
||||
port_http_proxy="$(ynh_app_setting_get --app=$app --key=port_http_proxy)"
|
||||
enable_terminal="$(ynh_app_setting_get --app=$app --key=enable_terminal)"
|
||||
enable_extensions="$(ynh_app_setting_get --app=$app --key=enable_extensions)"
|
||||
#REMOVEME? domain="$(ynh_app_setting_get --app=$app --key=domain)"
|
||||
#REMOVEME? path="$(ynh_app_setting_get --app=$app --key=path)"
|
||||
#REMOVEME? admin="$(ynh_app_setting_get --app=$app --key=admin)"
|
||||
#REMOVEME? #REMOVEME? install_dir="$(ynh_app_setting_get --app=$app --key=install_dir)"
|
||||
#REMOVEME? port="$(ynh_app_setting_get --app=$app --key=port)"
|
||||
#REMOVEME? port_hub="$(ynh_app_setting_get --app=$app --key=port_hub)"
|
||||
#REMOVEME? port_http_proxy="$(ynh_app_setting_get --app=$app --key=port_http_proxy)"
|
||||
#REMOVEME? enable_terminal="$(ynh_app_setting_get --app=$app --key=enable_terminal)"
|
||||
#REMOVEME? enable_extensions="$(ynh_app_setting_get --app=$app --key=enable_extensions)"
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
|
@ -50,20 +50,20 @@ ynh_remove_systemd_config
|
|||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing dependencies..." --weight=4
|
||||
#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=4
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_app_dependencies
|
||||
#REMOVEME? ynh_remove_app_dependencies
|
||||
|
||||
ynh_remove_nodejs
|
||||
|
||||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing app main directory..." --weight=1
|
||||
#REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=1
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove --file="$final_path"
|
||||
#REMOVEME? ynh_secure_remove --file="$install_dir"
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
|
@ -106,10 +106,10 @@ fi
|
|||
#=================================================
|
||||
# REMOVE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
|
||||
#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." --weight=1
|
||||
|
||||
# Delete a system user
|
||||
ynh_system_user_delete --username=$app
|
||||
#REMOVEME? ynh_system_user_delete --username=$app
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
|
@ -14,35 +14,35 @@ source /usr/share/yunohost/helpers
|
|||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
#REMOVEME? ynh_clean_setup () {
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
#REMOVEME? ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading settings..." --weight=1
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain="$(ynh_app_setting_get --app=$app --key=domain)"
|
||||
path_url="$(ynh_app_setting_get --app=$app --key=path)"
|
||||
admin="$(ynh_app_setting_get --app=$app --key=admin)"
|
||||
final_path="$(ynh_app_setting_get --app=$app --key=final_path)"
|
||||
port="$(ynh_app_setting_get --app=$app --key=port)"
|
||||
port_hub="$(ynh_app_setting_get --app=$app --key=port_hub)"
|
||||
port_http_proxy="$(ynh_app_setting_get --app=$app --key=port_http_proxy)"
|
||||
enable_terminal="$(ynh_app_setting_get --app=$app --key=enable_terminal)"
|
||||
enable_extensions="$(ynh_app_setting_get --app=$app --key=enable_extensions)"
|
||||
#REMOVEME? domain="$(ynh_app_setting_get --app=$app --key=domain)"
|
||||
#REMOVEME? path="$(ynh_app_setting_get --app=$app --key=path)"
|
||||
#REMOVEME? admin="$(ynh_app_setting_get --app=$app --key=admin)"
|
||||
#REMOVEME? #REMOVEME? install_dir="$(ynh_app_setting_get --app=$app --key=install_dir)"
|
||||
#REMOVEME? port="$(ynh_app_setting_get --app=$app --key=port)"
|
||||
#REMOVEME? port_hub="$(ynh_app_setting_get --app=$app --key=port_hub)"
|
||||
#REMOVEME? port_http_proxy="$(ynh_app_setting_get --app=$app --key=port_http_proxy)"
|
||||
#REMOVEME? enable_terminal="$(ynh_app_setting_get --app=$app --key=enable_terminal)"
|
||||
#REMOVEME? enable_extensions="$(ynh_app_setting_get --app=$app --key=enable_extensions)"
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
||||
#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
||||
|
||||
test ! -d $final_path || ynh_die --message="There is already a directory: $final_path "
|
||||
#REMOVEME? test ! -d $install_dir || ynh_die --message="There is already a directory: $install_dir "
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
|
@ -55,40 +55,40 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
||||
#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app
|
||||
#REMOVEME? ynh_system_user_create --username=$app
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..." --weight=5
|
||||
|
||||
ynh_restore_file --origin_path="$final_path"
|
||||
ynh_restore_file --origin_path="$install_dir"
|
||||
|
||||
#=================================================
|
||||
# RESTORE USER RIGHTS
|
||||
#=================================================
|
||||
|
||||
# Restore permissions on app files
|
||||
mkdir -p "$final_path/.venv"
|
||||
mkdir -p "$install_dir/.venv"
|
||||
|
||||
chown -R $app:$app "$final_path"
|
||||
chmod -R g=u,g-w,o-rwx "$final_path"
|
||||
chown -R $app:$app "$install_dir"
|
||||
chmod -R g=u,g-w,o-rwx "$install_dir"
|
||||
|
||||
setfacl -nR -m g:$app.main:rx -m d:g:$app.main:rx "$final_path/.venv"
|
||||
setfacl -n -m g:$app.main:x "$final_path"
|
||||
setfacl -nR -m g:$app.main:rx -m d:g:$app.main:rx "$install_dir/.venv"
|
||||
setfacl -n -m g:$app.main:x "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=75
|
||||
#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=75
|
||||
|
||||
# Define and install dependencies
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||
|
||||
|
@ -112,11 +112,11 @@ ynh_script_progression --message="Restoring sudoers configuration..." --weight=2
|
|||
ynh_restore_file --origin_path="/etc/sudoers.d/$app-sudoers"
|
||||
|
||||
# Set permissions on app files
|
||||
chmod 550 "$final_path/.venv/bin/sudospawner-singleuser"
|
||||
chown -R $app:$app "$final_path"
|
||||
chmod -R g=u,g-w,o-rwx "$final_path"
|
||||
setfacl -nR -m g:$app.main:rx -m d:g:$app.main:rx "$final_path/.venv"
|
||||
setfacl -n -m g:$app.main:x "$final_path"
|
||||
chmod 550 "$install_dir/.venv/bin/sudospawner-singleuser"
|
||||
chown -R $app:$app "$install_dir"
|
||||
chmod -R g=u,g-w,o-rwx "$install_dir"
|
||||
setfacl -nR -m g:$app.main:rx -m d:g:$app.main:rx "$install_dir/.venv"
|
||||
setfacl -n -m g:$app.main:x "$install_dir"
|
||||
chown root:root "/etc/sudoers.d/$app-sudoers"
|
||||
chmod 440 "/etc/sudoers.d/$app-sudoers"
|
||||
|
||||
|
|
|
@ -12,19 +12,19 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=3
|
||||
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=3
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain="$(ynh_app_setting_get --app=$app --key=domain)"
|
||||
path_url="$(ynh_app_setting_get --app=$app --key=path)"
|
||||
admin="$(ynh_app_setting_get --app=$app --key=admin)"
|
||||
final_path="$(ynh_app_setting_get --app=$app --key=final_path)"
|
||||
port="$(ynh_app_setting_get --app=$app --key=port)"
|
||||
port_hub="$(ynh_app_setting_get --app=$app --key=port_hub)"
|
||||
port_http_proxy="$(ynh_app_setting_get --app=$app --key=port_http_proxy)"
|
||||
enable_terminal="$(ynh_app_setting_get --app=$app --key=enable_terminal)"
|
||||
enable_extensions="$(ynh_app_setting_get --app=$app --key=enable_extensions)"
|
||||
#REMOVEME? domain="$(ynh_app_setting_get --app=$app --key=domain)"
|
||||
#REMOVEME? path="$(ynh_app_setting_get --app=$app --key=path)"
|
||||
#REMOVEME? admin="$(ynh_app_setting_get --app=$app --key=admin)"
|
||||
#REMOVEME? #REMOVEME? install_dir="$(ynh_app_setting_get --app=$app --key=install_dir)"
|
||||
#REMOVEME? port="$(ynh_app_setting_get --app=$app --key=port)"
|
||||
#REMOVEME? port_hub="$(ynh_app_setting_get --app=$app --key=port_hub)"
|
||||
#REMOVEME? port_http_proxy="$(ynh_app_setting_get --app=$app --key=port_http_proxy)"
|
||||
#REMOVEME? enable_terminal="$(ynh_app_setting_get --app=$app --key=enable_terminal)"
|
||||
#REMOVEME? enable_extensions="$(ynh_app_setting_get --app=$app --key=enable_extensions)"
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
|
@ -43,18 +43,18 @@ if [ -z "$enable_extensions" ]; then
|
|||
fi
|
||||
|
||||
|
||||
# If final_path doesn't exist, create it
|
||||
if [ -z "$final_path" ]; then
|
||||
final_path=/opt/yunohost/$app
|
||||
# If install_dir doesn't exist, create it
|
||||
if [ -z "$install_dir" ]; then
|
||||
#REMOVEME? install_dir=/opt/yunohost/$app
|
||||
|
||||
mkdir -p $final_path
|
||||
mkdir -p $install_dir
|
||||
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
|
||||
fi
|
||||
|
||||
# Cleaning legacy permissions
|
||||
if ynh_legacy_permissions_exists; then
|
||||
ynh_legacy_permissions_delete_all
|
||||
#REMOVEME? if ynh_legacy_permissions_exists; then
|
||||
#REMOVEME? ynh_legacy_permissions_delete_all
|
||||
|
||||
ynh_app_setting_delete --app=$app --key=is_public
|
||||
fi
|
||||
|
@ -62,18 +62,18 @@ fi
|
|||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=48
|
||||
#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=48
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
#REMOVEME? ynh_backup_before_upgrade
|
||||
#REMOVEME? ynh_clean_setup () {
|
||||
ynh_clean_check_starting
|
||||
|
||||
# restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
#REMOVEME? ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
#REMOVEME? ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
|
@ -95,17 +95,17 @@ ynh_add_nginx_config
|
|||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
|
||||
#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
|
||||
|
||||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app
|
||||
#REMOVEME? ynh_system_user_create --username=$app
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..." --weight=83
|
||||
#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=83
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||
|
||||
|
@ -122,13 +122,13 @@ then
|
|||
ynh_script_progression --message="Upgrading source files..." --weight=160
|
||||
|
||||
# Set permissions to app files
|
||||
mkdir -p "$final_path/.venv"
|
||||
chown -R $app:$app "$final_path"
|
||||
chmod -R g=u,g-w,o-rwx "$final_path"
|
||||
setfacl -nR -m g:$app.main:rx -m d:g:$app.main:rx "$final_path/.venv"
|
||||
setfacl -n -m g:$app.main:x "$final_path"
|
||||
mkdir -p "$install_dir/.venv"
|
||||
chown -R $app:$app "$install_dir"
|
||||
chmod -R g=u,g-w,o-rwx "$install_dir"
|
||||
setfacl -nR -m g:$app.main:rx -m d:g:$app.main:rx "$install_dir/.venv"
|
||||
setfacl -n -m g:$app.main:x "$install_dir"
|
||||
|
||||
pushd "$final_path"
|
||||
pushd "$install_dir"
|
||||
sudo -u $app PIPENV_VENV_IN_PROJECT="enabled" PIPENV_SKIP_LOCK=true python3 -m pipenv install jupyterlab==$jupyterlab_version jupyterhub notebook jupyter-server jupyterhub-ldapauthenticator pyzmq sudospawner --three 2>&1
|
||||
sudo -u $app python3 -m pipenv run jupyterhub upgrade-db 2>&1
|
||||
popd
|
||||
|
@ -140,13 +140,13 @@ fi
|
|||
# STORE THE CONFIG FILE CHECKSUM
|
||||
#=================================================
|
||||
|
||||
mkdir -p "$final_path/config"
|
||||
path="${path_url%/}"
|
||||
mkdir -p "$install_dir/config"
|
||||
path="${path%/}"
|
||||
|
||||
ynh_add_config --template="jupyterhub_config.py" --destination="$final_path/config/jupyterhub_config.py"
|
||||
ynh_add_config --template="jupyter_server_config.py" --destination="$final_path/config/jupyter_server_config.py"
|
||||
ynh_add_config --template="jupyterhub_config.py" --destination="$install_dir/config/jupyterhub_config.py"
|
||||
ynh_add_config --template="jupyter_server_config.py" --destination="$install_dir/config/jupyter_server_config.py"
|
||||
ynh_add_config --template="app-sudoers" --destination="/etc/sudoers.d/$app-sudoers"
|
||||
ynh_add_config --template="sudospawner-singleuser" --destination="$final_path/.venv/bin/sudospawner-singleuser"
|
||||
ynh_add_config --template="sudospawner-singleuser" --destination="$install_dir/.venv/bin/sudospawner-singleuser"
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
|
@ -165,11 +165,11 @@ ynh_add_systemd_config
|
|||
#=================================================
|
||||
|
||||
# Set permissions on app files
|
||||
chmod 550 "$final_path/.venv/bin/sudospawner-singleuser"
|
||||
chown -R $app:$app "$final_path"
|
||||
chmod -R g=u,g-w,o-rwx "$final_path"
|
||||
setfacl -nR -m g:$app.main:rx -m d:g:$app.main:rx "$final_path/.venv"
|
||||
setfacl -n -m g:$app.main:x "$final_path"
|
||||
chmod 550 "$install_dir/.venv/bin/sudospawner-singleuser"
|
||||
chown -R $app:$app "$install_dir"
|
||||
chmod -R g=u,g-w,o-rwx "$install_dir"
|
||||
setfacl -nR -m g:$app.main:rx -m d:g:$app.main:rx "$install_dir/.venv"
|
||||
setfacl -n -m g:$app.main:x "$install_dir"
|
||||
chown root:root "/etc/sudoers.d/$app-sudoers"
|
||||
chmod 440 "/etc/sudoers.d/$app-sudoers"
|
||||
|
||||
|
@ -184,7 +184,7 @@ if [ $enable_extensions -eq 1 ]; then
|
|||
for user in $(ynh_user_list); do
|
||||
JUPYTERLAB_DIR="$(getent passwd $user | cut -d: -f6)/.local/share/$app/lab"
|
||||
node_path="$nodejs_path:$(sudo -u $user sh -c 'echo $PATH')"
|
||||
sudo -u $user env "PATH=$node_path" "$final_path/.venv/bin/jupyter" lab build --app-dir="$JUPYTERLAB_DIR"
|
||||
sudo -u $user env "PATH=$node_path" "$install_dir/.venv/bin/jupyter" lab build --app-dir="$JUPYTERLAB_DIR"
|
||||
done
|
||||
fi
|
||||
|
||||
|
@ -204,9 +204,9 @@ ynh_systemd_action --service_name=$app --action=start --line_match="JupyterHub i
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
Loading…
Add table
Reference in a new issue