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

Merge branch 'testing' into yunohost-11

This commit is contained in:
ericgaspar 2022-04-16 07:18:35 +02:00
commit 58811716c6
15 changed files with 95 additions and 85 deletions

View file

@ -17,6 +17,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
JupyterLab is the next-generation user interface for Project Jupyter offering all the familiar building blocks of the classic Jupyter Notebook (notebook, terminal, text editor, file browser, rich outputs, etc.) in a flexible and powerful user interface. JupyterLab will eventually replace the classic Jupyter Notebook.
**Shipped version:** 4.0.0~ynh4

View file

@ -2,8 +2,8 @@
; Manifest
domain="domain.tld"
path="/jupyterlab"
admin="john"
is_public=1
admin="john"
; Checks
pkg_linter=1
setup_sub_dir=1
@ -12,9 +12,11 @@
setup_private=1
setup_public=1
upgrade=1
# 3.0.16~ynh1
upgrade=1 from_commit=197dca5095e29abe8d4a560a5a2ba2984045c989
backup_restore=1
multi_instance=1
port_already_use=1
port_already_use=0
change_url=1
;;; Options
Email=

View file

@ -1,3 +1,4 @@
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {
proxy_pass http://127.0.0.1:__PORT__;

View file

@ -3,6 +3,9 @@ Description=JupyterLab
After=syslog.target network.target
[Service]
Type=simple
User=root
WorkingDirectory=__FINALPATH__/
Environment="LC_ALL=C.UTF-8"
Environment="LANG=C.UTF-8"
WorkingDirectory=__FINALPATH__

0
doc/.gitkeep Normal file
View file

View file

@ -1 +1,2 @@
JupyterLab is the next-generation user interface for Project Jupyter offering all the familiar building blocks of the classic Jupyter Notebook (notebook, terminal, text editor, file browser, rich outputs, etc.) in a flexible and powerful user interface. JupyterLab will eventually replace the classic Jupyter Notebook.

0
doc/DISCLAIMER.md Normal file
View file

0
doc/screenshots/.gitkeep Normal file
View file

View file

@ -47,6 +47,10 @@
"type": "boolean",
"default": true
},
{
"name": "admin",
"type": "user"
},
{
"name": "enable_terminal",
"type": "boolean",

View file

@ -6,7 +6,7 @@
# IMPORT GENERIC HELPERS
#=================================================
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers

View file

@ -28,19 +28,22 @@ ynh_script_progression --message="Loading installation settings..."
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# Add settings here as needed by your application
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)
admin=$(ynh_app_setting_get --app=$app --key=admin)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_clean_check_starting
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"

View file

@ -59,13 +59,14 @@ ynh_app_setting_set --app=$app --key=enable_terminal --value=$enable_terminal
#=================================================
ynh_script_progression --message="Finding an available port..." --weight=1
# Find a free port
# Find an available 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)))
ynh_app_setting_set --app=$app --key=port --value=$port
port_hub=$(ynh_find_port --port=$(($port + 1)))
ynh_app_setting_set --app=$app --key=port_hub --value=$port_hub
port_http_proxy=$(ynh_find_port --port=$(($port_hub + 1)))
ynh_app_setting_set --app=$app --key=port_http_proxy --value=$port_http_proxy
#=================================================
@ -74,9 +75,9 @@ ynh_app_setting_set --app=$app --key=port_http_proxy --value=$port_http_proxy
ynh_script_progression --message="Installing dependencies..." --weight=23
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
npm install -g configurable-http-proxy
@ -112,14 +113,14 @@ ynh_add_nginx_config
#=================================================
# SPECIFIC SETUP
#=================================================
# SETUP SYSTEMD
# BUILD APP
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=3
ynh_script_progression --message="Building app..."
ynh_add_systemd_config
#=================================================
# MODIFY A CONFIG FILE
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
@ -129,22 +130,25 @@ path=${path_url%/}
ynh_add_config --template="../conf/jupyterhub_config.py" --destination="$final_path/config/jupyterhub_config.py"
ynh_add_config --template="../conf/jupyter_notebook_config.py" --destination="$final_path/config/jupyter_notebook_config.py"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions to app files
chown -R root: $final_path/
chown -R $admin: $final_path/.venv/
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
# 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..." --weight=1
yunohost service add $app --description="$app daemon" --log="$app"
yunohost service add $app --description="$app daemon"
#=================================================
# START SYSTEMD SERVICE

View file

@ -17,21 +17,18 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
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)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE SERVICE FROM ADMIN PANEL
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#=================================================
# Remove a service from the admin panel, added by `yunohost service add`
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null
then
ynh_script_progression --message="Removing $app service..." --weight=2
ynh_script_progression --message="Removing $app service integration..."--weight=2
yunohost service remove $app
fi
@ -43,16 +40,6 @@ ynh_script_progression --message="Stopping and removing the systemd service..."
# Remove the dedicated systemd config
ynh_remove_systemd_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=4
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
ynh_remove_nodejs
#=================================================
# REMOVE APP MAIN DIR
#=================================================
@ -70,12 +57,13 @@ ynh_script_progression --message="Removing NGINX web server configuration..." --
ynh_remove_nginx_config
#=================================================
# REMOVE DEDICATED USER
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
ynh_script_progression --message="Removing dependencies..." --weight=4
# Delete a system user
ynh_system_user_delete --username=$app
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
ynh_remove_nodejs
#=================================================
# END OF SCRIPT

View file

@ -6,7 +6,7 @@
# IMPORT GENERIC HELPERS
#=================================================
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@ -23,21 +23,22 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading settings..." --weight=1
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
admin=$(ynh_app_setting_get --app=$app --key=admin)
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
admin=$(ynh_app_setting_get --app=$app --key=admin)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1
test ! -d $final_path || ynh_die --message="There is already a directory: $final_path "
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
@ -80,13 +81,11 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=75
# Define and install dependencies
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
npm install -g configurable-http-proxy
#=================================================
# RESTORE SYSTEMD
#=================================================
@ -96,18 +95,18 @@ ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="$app daemon" --log="$app"
yunohost service add $app --description="$app daemon"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=5
ynh_systemd_action --service_name=$app --action=start --line_match="JupyterHub is now running at" --log_path="systemd"
ynh_systemd_action --service_name=$app --action="start" --line_match="JupyterHub is now running at" --log_path="systemd"
#=================================================
# GENERIC FINALIZATION

View file

@ -28,6 +28,7 @@ enable_terminal=$(ynh_app_setting_get --app=$app --key=enable_terminal)
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
@ -75,19 +76,32 @@ ynh_script_progression --message="Stopping a systemd service..." --weight=2
ynh_systemd_action --service_name=$app --action="stop"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
# If final_path doesn't exist, create it
if [ -z "$final_path" ]; then
final_path=/opt/$app
mkdir -p $final_path
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
fi
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
# Create a dedicated nginx config
ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
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 --home_dir="$final_path"
@ -97,23 +111,20 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
ynh_script_progression --message="Upgrading dependencies..." --weight=83
ynh_install_app_dependencies $pkg_dependencies
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
npm install -g configurable-http-proxy
ynh_use_nodejs
$ynh_npm install -g configurable-http-proxy
python3 -m pip install pipenv
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
# SPECIFIC UPGRADE
#=================================================
# BUILD APP
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=160
# Download, check integrity, uncompress and patch the source from app.src
mkdir -p $final_path
ynh_script_progression --message="Building app..." --weight=160
pushd $final_path
PIPENV_VENV_IN_PROJECT="enabled" PIPENV_SKIP_LOCK=true ynh_exec_warn_less python3 -m pipenv install jupyterlab==$jupyterlab_version jupyterhub notebook jupyterhub-ldapauthenticator pyzmq
@ -122,9 +133,7 @@ then
fi
#=================================================
# SPECIFIC UPGRADE
#=================================================
# STORE THE CONFIG FILE CHECKSUM
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=1
@ -134,6 +143,9 @@ path=${path_url%/}
ynh_add_config --template="../conf/jupyterhub_config.py" --destination="$final_path/config/jupyterhub_config.py"
ynh_add_config --template="../conf/jupyter_notebook_config.py" --destination="$final_path/config/jupyter_notebook_config.py"
chown -R root: $final_path/
chown -R $admin: $final_path/.venv/
#=================================================
# SETUP SYSTEMD
#=================================================
@ -144,19 +156,11 @@ ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions on app files
chown -R root: $final_path/
chown -R $admin: $final_path/.venv/
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="$app daemon" --log="$app"
yunohost service add $app --description="$app daemon"
#=================================================
# START SYSTEMD SERVICE