diff --git a/README.md b/README.md index ec4718a..dc95efa 100644 --- a/README.md +++ b/README.md @@ -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 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 2c2c3ba..a8f36a5 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://127.0.0.1:__PORT__; diff --git a/conf/systemd.service b/conf/systemd.service index ae1d931..5dbe426 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -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__ 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 index c26fe43..513df10 100644 --- a/doc/DESCRIPTION.md +++ b/doc/DESCRIPTION.md @@ -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. \ No newline at end of file +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/manifest.json b/manifest.json index be54608..b6c209a 100644 --- a/manifest.json +++ b/manifest.json @@ -47,6 +47,10 @@ "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 b74afa9..eef8559 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" diff --git a/scripts/install b/scripts/install index c58d192..ad5f66c 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,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 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 1404b9f..50457db 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,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 diff --git a/scripts/upgrade b/scripts/upgrade index b4624ba..f22f92a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -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