diff --git a/check_process b/check_process index c42f668..ce98261 100644 --- a/check_process +++ b/check_process @@ -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= diff --git a/conf/nginx.conf b/conf/nginx.conf index 4d70d5a..4de7a6a 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,3 +1,4 @@ +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__/ { proxy_pass http://localhost:__PORT__; proxy_redirect off; diff --git a/conf/systemd.service b/conf/systemd.service index c10f8f0..a6c56ff 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -3,13 +3,15 @@ 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" -Environment="PATH=__NODE_PATH__:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" -ExecStart=/usr/local/bin/pipenv run jupyterhub -f __FINALPATH__/config/jupyterhub_config.py +Environment="__YNH_NODE_LOAD_PATH__:__FINALPATH__/.venv/bin" +ExecStart=__FINALPATH__/.venv/bin/jupyterhub -f __FINALPATH__/config/jupyterhub_config.py --upgrade-db Restart=always RestartSec=10 -WorkingDirectory=__FINALPATH__ [Install] -WantedBy=multi-user.target \ No newline at end of file +WantedBy=multi-user.target diff --git a/doc/.gitkeep b/doc/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md new file mode 100644 index 0000000..5572589 --- /dev/null +++ b/doc/DESCRIPTION.md @@ -0,0 +1 @@ +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. diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md new file mode 100644 index 0000000..e69de29 diff --git a/doc/screenshots/.gitkeep b/doc/screenshots/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/doc/screenshots/jupyterlab.png b/doc/screenshots/jupyterlab.png new file mode 100644 index 0000000..54dac35 Binary files /dev/null and b/doc/screenshots/jupyterlab.png differ diff --git a/manifest.json b/manifest.json index c852dcc..2575aef 100644 --- a/manifest.json +++ b/manifest.json @@ -8,13 +8,20 @@ }, "version": "3.0.16~ynh1", "url": "https://jupyterlab.readthedocs.io/en/stable/", + "upstream": { + "license": "BSD-3-Clause", + "website": "https://jupyterlab.readthedocs.io/en/stable/", + "demo": "https://mybinder.org/v2/gh/jupyterlab/jupyterlab-demo/master?urlpath=lab/tree/demo", + "admindoc": "https://jupyterlab.readthedocs.io/en/stable/", + "code": "https://github.com/jupyterhub/jupyterhub" + }, "license": "BSD-3-Clause", "maintainer": { "name": "kay0u", "email": "pierre@kayou.io" }, "requirements": { - "yunohost": ">= 4.1.7" + "yunohost": ">= 4.3.0" }, "multi_instance": true, "services": [ @@ -24,8 +31,7 @@ "install": [ { "name": "domain", - "type": "domain", - "example": "example.com" + "type": "domain" }, { "name": "path", @@ -33,16 +39,15 @@ "example": "/jupyterlab", "default": "/jupyterlab" }, - { - "name": "admin", - "type": "user", - "example": "johndoe" - }, { "name": "is_public", "type": "boolean", "default": true }, + { + "name": "admin", + "type": "user" + }, { "name": "enable_terminal", "type": "boolean", diff --git a/scripts/backup b/scripts/backup index 2938068..d72c557 100644 --- a/scripts/backup +++ b/scripts/backup @@ -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 diff --git a/scripts/change_url b/scripts/change_url index df385d7..e26ce2d 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -24,23 +24,26 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +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" @@ -71,14 +74,14 @@ fi #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." +ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --service_name=$app --action="stop" #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." +ynh_script_progression --message="Updating NGINX web server configuration..." nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -120,14 +123,15 @@ ynh_add_config --template="../conf/jupyterhub_config.py" --destination="$final_p #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression --message="Starting a systemd service..." +# Start a systemd service ynh_systemd_action --service_name=$app --action="start" --line_match="JupyterHub is now running at" --log_path="systemd" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/install b/scripts/install index 290fff2..7e63872 100644 --- a/scripts/install +++ b/scripts/install @@ -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,83 +75,65 @@ 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 - -#================================================= -# DOWNLOAD, CHECK AND UNPACK SOURCE -#================================================= -ynh_script_progression --message="Setting up source files..." --weight=64 - -ynh_app_setting_set --app=$app --key=final_path --value=$final_path - -mkdir -p $final_path - -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 --three - -popd - #================================================= # NGINX CONFIGURATION #================================================= ynh_script_progression --message="Configuring NGINX web server..." --weight=1 -# Create a dedicated nginx config +# Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --weight=1 - -# Create a system user -ynh_system_user_create --username=$app - #================================================= # SPECIFIC SETUP #================================================= -# SETUP SYSTEMD +# BUILD APP #================================================= -ynh_script_progression --message="Configuring a systemd service..." --weight=3 +ynh_script_progression --message="Building app..." -# Create a dedicated systemd config -ynh_replace_string --match_string="__NODE_PATH__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" +ynh_app_setting_set --app=$app --key=final_path --value=$final_path +mkdir -p "$final_path" -ynh_add_systemd_config +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 --three +popd #================================================= -# MODIFY A CONFIG FILE +# ADD A CONFIGURATION #================================================= +ynh_script_progression --message="Adding a configuration file..." mkdir -p "$final_path/config" 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 -yunohost service add $app --description="$app daemon" --log="$app" +# 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 diff --git a/scripts/remove b/scripts/remove index 2fc6809..a4d5e6e 100644 --- a/scripts/remove +++ b/scripts/remove @@ -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 diff --git a/scripts/restore b/scripts/restore index 5dc2da6..c2ff4d9 100644 --- a/scripts/restore +++ b/scripts/restore @@ -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,22 +23,20 @@ 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 -ynh_webpath_available --domain=$domain --path_url=$path_url \ - || ynh_die --message="Path not available: ${domain}${path_url}" test ! -d $final_path \ || ynh_die --message="There is already a directory: $final_path " @@ -47,6 +45,7 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Restoring the NGINX web server configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" @@ -57,19 +56,6 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$final_path" -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 - -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app - -#================================================= -# RESTORE USER RIGHTS -#================================================= - -# Restore permissions on app files chown -R root: $final_path/ chown -R $admin: $final_path/.venv/ @@ -82,13 +68,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 #================================================= @@ -98,17 +82,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..." -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 diff --git a/scripts/upgrade b/scripts/upgrade index 5633efb..e34fec2 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -28,9 +28,34 @@ 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) +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +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 () { + ynh_clean_check_starting + # Restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# STANDARD UPGRADE STEPS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." --weight=2 + +ynh_systemd_action --service_name=$app --action="stop" + #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -52,86 +77,45 @@ if ynh_legacy_permissions_exists; then ynh_app_setting_delete --app=$app --key=is_public fi -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -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 () { - ynh_clean_check_starting - - # restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# STANDARD UPGRADE STEPS -#================================================= -# STOP SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=2 - -ynh_systemd_action --service_name=$app --action="stop" - #================================================= # NGINX CONFIGURATION #================================================= ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 -# Create a dedicated nginx config +# 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 - #================================================= # UPGRADE DEPENDENCIES #================================================= 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 -#================================================= - -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 - - 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 - - ynh_exec_warn_less python3 -m pipenv run jupyterhub upgrade-db - - popd -fi - #================================================= # SPECIFIC UPGRADE #================================================= -# STORE THE CONFIG FILE CHECKSUM +# BUILD APP #================================================= +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + 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 + popd +fi + +#================================================= +# UPDATE A CONFIG FILE +#================================================= +ynh_script_progression --message="Updating a configuration file..." + mkdir -p "$final_path/config" path=${path_url%/} @@ -140,29 +124,23 @@ ynh_add_config --template="../conf/jupyterhub_config.py" --destination="$final_p 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 #================================================= ynh_script_progression --message="Upgrading systemd configuration..." # Create a dedicated systemd config -ynh_replace_string --match_string="__NODE_PATH__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" - 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..." yunohost service add $app --description="$app daemon" --log="$app" @@ -171,7 +149,7 @@ yunohost service add $app --description="$app daemon" --log="$app" #================================================= ynh_script_progression --message="Starting a systemd service..." -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" #================================================= # RELOAD NGINX