From 88bed78364c56eb164d73591441f876c2987f60b Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 24 Feb 2022 23:08:37 +0100 Subject: [PATCH] Fix --- conf/nginx.conf | 4 ++- conf/systemd.service | 6 ++--- manifest.json | 6 ++--- scripts/change_url | 10 +++---- scripts/install | 18 +++++-------- scripts/restore | 4 ++- scripts/upgrade | 64 +++++++++++++++++++------------------------- 7 files changed, 51 insertions(+), 61 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 4d70d5a..2c2c3ba 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,5 +1,6 @@ location __PATH__/ { - proxy_pass http://localhost:__PORT__; + + proxy_pass http://127.0.0.1:__PORT__; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -10,6 +11,7 @@ location __PATH__/ { proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; + # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; more_clear_input_headers 'Accept-Encoding'; diff --git a/conf/systemd.service b/conf/systemd.service index c10f8f0..ae1d931 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -5,11 +5,11 @@ After=syslog.target network.target [Service] 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" +WorkingDirectory=__FINALPATH__ +Environment="__YNH_NODE_LOAD_PATH__" ExecStart=/usr/local/bin/pipenv run jupyterhub -f __FINALPATH__/config/jupyterhub_config.py Restart=always RestartSec=10 -WorkingDirectory=__FINALPATH__ [Install] -WantedBy=multi-user.target \ No newline at end of file +WantedBy=multi-user.target diff --git a/manifest.json b/manifest.json index b262d11..82efe00 100644 --- a/manifest.json +++ b/manifest.json @@ -3,10 +3,10 @@ "id": "jupyterlab", "packaging_format": 1, "description": { - "en": "Code console environment for running Python code interactively.", - "fr": "Console de code pour exécuter du code Python de manière interactive." + "en": "Code console environment for running Python code interactively", + "fr": "Console de code pour exécuter du code Python de manière interactive" }, - "version": "4.0.0~ynh1", + "version": "4.0.0~ynh2", "url": "https://jupyter.org", "upstream": { "license": "BSD-3-Clause", diff --git a/scripts/change_url b/scripts/change_url index df385d7..b74afa9 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -71,14 +71,14 @@ fi #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." +ynh_script_progression --message="Stopping a systemd service..." --weight=1 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..." --weight=1 nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -120,14 +120,14 @@ 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..." --weight=1 -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" --log_path="systemd" --line_match="JupyterHub is now running at" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/install b/scripts/install index 61fc041..c58d192 100644 --- a/scripts/install +++ b/scripts/install @@ -36,7 +36,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= ynh_script_progression --message="Validating installation parameters..." --weight=1 -final_path=/opt/$app +final_path=/var/www/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" # Register (book) web path @@ -95,13 +95,10 @@ ynh_system_user_create --username=$app --home_dir="$final_path" 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 jupyterlab-language-pack-fr-FR --three - + 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 jupyterlab-language-pack-fr-FR --three popd #================================================= @@ -109,7 +106,7 @@ popd #================================================= ynh_script_progression --message="Configuring NGINX web server..." --weight=1 -# Create a dedicated nginx config +# Create a dedicated NGINX config ynh_add_nginx_config #================================================= @@ -119,21 +116,17 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Configuring a systemd service..." --weight=3 -# 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 #================================================= # MODIFY A CONFIG FILE #================================================= +ynh_script_progression --message="Adding a configuration file..." --weight=1 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" #================================================= @@ -149,6 +142,7 @@ chown -R $admin: $final_path/.venv/ #================================================= # ADVERTISE SERVICE IN ADMIN PANEL #================================================= +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 yunohost service add $app --description="$app daemon" --log="$app" @@ -158,7 +152,7 @@ yunohost service add $app --description="$app daemon" --log="$app" ynh_script_progression --message="Starting a systemd service..." --weight=3 # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --line_match="JupyterHub is now running at" --log_path="systemd" +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="JupyterHub is now running at" #================================================= # SETUP SSOWAT diff --git a/scripts/restore b/scripts/restore index 719b8cd..1404b9f 100644 --- a/scripts/restore +++ b/scripts/restore @@ -44,6 +44,7 @@ test ! -d $final_path || ynh_die --message="There is already a directory: $final #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Restoring the NGINX configuration..." --weight=1 ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" @@ -60,7 +61,7 @@ ynh_restore_file --origin_path="$final_path" ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 # Create the dedicated user (if not existing) -ynh_system_user_create --username=$app +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # RESTORE USER RIGHTS @@ -97,6 +98,7 @@ systemctl enable $app.service --quiet #================================================= # ADVERTISE SERVICE IN ADMIN PANEL #================================================= +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 yunohost service add $app --description="$app daemon" --log="$app" diff --git a/scripts/upgrade b/scripts/upgrade index 5633efb..b4624ba 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -31,27 +31,6 @@ enable_terminal=$(ynh_app_setting_get --app=$app --key=enable_terminal) upgrade_type=$(ynh_check_app_version_changed) -#================================================= -# 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 - #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -68,6 +47,25 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors +#================================================= +# 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=/var/www/$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 + #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -91,7 +89,7 @@ ynh_add_nginx_config 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 +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # UPGRADE DEPENDENCIES @@ -118,11 +116,8 @@ then 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 - + 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 @@ -131,22 +126,18 @@ fi #================================================= # STORE THE CONFIG FILE CHECKSUM #================================================= +ynh_script_progression --message="Updating a configuration file..." --weight=1 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" #================================================= # 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_script_progression --message="Upgrading systemd configuration..." --weight=1 ynh_add_systemd_config @@ -163,20 +154,21 @@ chown -R $admin: $final_path/.venv/ #================================================= # ADVERTISE SERVICE IN ADMIN PANEL #================================================= +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 yunohost service add $app --description="$app daemon" --log="$app" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression --message="Starting a systemd service..." --weight=3 -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 --log_path="systemd" --line_match="JupyterHub is now running at" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload