1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/jupyterlab_ynh.git synced 2024-09-03 19:26:35 +02:00
This commit is contained in:
YunoHost Bot 2024-09-01 18:14:07 +02:00 committed by GitHub
commit 23d31b3c98
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 71 additions and 101 deletions

View file

@ -8,7 +8,7 @@ User=root
WorkingDirectory=__INSTALL_DIR__/
Environment="LC_ALL=C.UTF-8"
Environment="LANG=C.UTF-8"
Environment="__YNH_NODE_LOAD_PATH__:__INSTALL_DIR__/venv/bin"
Environment="PATH=__PATH_WITH_NODEJS__:__INSTALL_DIR__/venv/bin"
ExecStart=__INSTALL_DIR__/venv/bin/jupyterhub -f __INSTALL_DIR__/config/jupyterhub_config.py --upgrade-db
Restart=always
RestartSec=10

View file

@ -19,7 +19,8 @@ admindoc = "https://jupyterlab.readthedocs.io/en/stable/"
code = "https://github.com/jupyterhub/jupyterhub"
[integration]
yunohost = ">= 11.2"
yunohost = ">= 11.2.29"
helpers_version = "2.1"
architectures = "all"
multi_instance = false

View file

@ -1,26 +1,14 @@
#!/bin/bash
#=================================================
# COMMON VARIABLES
# COMMON VARIABLES AND CUSTOM HELPERS
#=================================================
nodejs_version="18"
#=================================================
# PERSONAL HELPERS
#=================================================
jupyterlab_upstream_version() {
upstream_repository=$(ynh_read_manifest --manifest_key='upstream.code')
upstream_url=$(ynh_read_manifest --manifest_key='resources.sources.main.url')
upstream_repository=$(ynh_read_manifest
upstream_url=$(ynh_read_manifest)
upstream_commit=$(echo "$upstream_url" | sed -e "s|^${upstream_repository}/archive/refs/tags/\(.*\)\.tar\.gz|\1|")
echo "$upstream_commit"
}
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -8,27 +8,24 @@
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
ynh_print_info "Declaring files to be backed up..."
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup --src_path="$install_dir"
ynh_backup "$install_dir"
#=================================================
# BACKUP THE SYSTEM CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup --src_path="/etc/systemd/system/$app.service"
ynh_backup "/etc/systemd/system/$app.service"
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -10,16 +10,16 @@ source /usr/share/yunohost/helpers
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping $app's systemd service..." --weight=1
ynh_script_progression "Stopping $app's systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
ynh_systemctl --service=$app --action="stop" --log_path="systemd"
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
ynh_script_progression "Updating NGINX web server configuration..."
ynh_change_url_nginx_config
ynh_config_change_url_nginx
#=================================================
# CONFIGURE JUPYTERLAB
@ -28,18 +28,18 @@ ynh_change_url_nginx_config
domain=$new_domain
path_no_slash=${new_path%/}
ynh_add_config --template="jupyterhub_config.py" --destination="$install_dir/config/jupyterhub_config.py"
ynh_config_add --template="jupyterhub_config.py" --destination="$install_dir/config/jupyterhub_config.py"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
ynh_script_progression "Starting $app's systemd service..."
# Start a systemd service
ynh_systemd_action --service_name="$app" --action="start" --line_match="JupyterHub is now running at" --log_path="systemd"
ynh_systemctl --service="$app" --action="start" --wait_until="JupyterHub is now running at" --log_path="systemd"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for $app" --last
ynh_script_progression "Change of URL completed for $app"

View file

@ -10,28 +10,27 @@ source /usr/share/yunohost/helpers
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing NodeJS..." --weight=15
ynh_script_progression "Installing NodeJS..."
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_use_nodejs
ynh_nodejs_install
ynh_exec_warn_less "$ynh_npm" install -g configurable-http-proxy
ynh_hide_warnings npm install -g configurable-http-proxy
#=================================================
# SET ADMIN GROUP
#=================================================
ynh_script_progression --message="Adding $admin to $app's group..." --weight=5
ynh_script_progression "Adding $admin to $app's group..."
usermod -a -G "$app" "$admin"
#=================================================
# BUILD APP
#=================================================
ynh_script_progression --message="Building app..." --weight=5
ynh_script_progression "Building app..."
python3 -m venv "$install_dir/venv"
ynh_exec_warn_less "$install_dir/venv/bin/python3" -m pip install \
ynh_hide_warnings "$install_dir/venv/bin/python3" -m pip install \
jupyterlab=="$(jupyterlab_upstream_version)" \
jupyterhub \
jupyter_collaboration \
@ -43,38 +42,34 @@ ynh_exec_warn_less "$install_dir/venv/bin/python3" -m pip install \
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding $app's configuration file..." --weight=1
ynh_script_progression "Adding $app's configuration file..."
mkdir -p "$install_dir/config"
path_no_slash=${path%/}
ynh_add_config --template="jupyterhub_config.py" --destination="$install_dir/config/jupyterhub_config.py"
ynh_add_config --template="jupyter_notebook_config.py" --destination="$install_dir/config/jupyter_notebook_config.py"
chown -R "$app:$app" "$install_dir"
ynh_config_add --template="jupyterhub_config.py" --destination="$install_dir/config/jupyterhub_config.py"
ynh_config_add --template="jupyter_notebook_config.py" --destination="$install_dir/config/jupyter_notebook_config.py"
#=================================================
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
ynh_script_progression "Adding system configurations related to $app..."
# Create a dedicated NGINX config
ynh_add_nginx_config
ynh_config_add_nginx
# Create a dedicated systemd config
ynh_add_systemd_config
ynh_config_add_systemd
yunohost service add "$app" --description="Console environment for running Python code" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting $app's systemd service..." --weight=3
ynh_script_progression "Starting $app's systemd service..."
# Start a systemd service
ynh_systemd_action --service_name="$app" --action="start" --line_match="JupyterHub is now running at" --log_path="systemd"
ynh_systemctl --service="$app" --action="start" --wait_until="JupyterHub is now running at" --log_path="systemd"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last
ynh_script_progression "Installation of $app completed"

View file

@ -10,23 +10,20 @@ source /usr/share/yunohost/helpers
#=================================================
# REMOVE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
ynh_script_progression "Removing system configurations related to $app..."
# 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
if ynh_hide_warnings yunohost service status "$app" >/dev/null; then
yunohost service remove "$app"
fi
# Remove the dedicated systemd config
ynh_remove_systemd_config
ynh_config_remove_systemd
# Remove the dedicated NGINX config
ynh_remove_nginx_config
ynh_config_remove_nginx
ynh_remove_nodejs
ynh_nodejs_remove
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed" --last
ynh_script_progression "Removal of $app completed"

View file

@ -4,58 +4,54 @@
# IMPORT GENERIC HELPERS
#=================================================
# 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
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling NodeJS..." --weight=15
ynh_script_progression "Reinstalling NodeJS..."
ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version"
ynh_use_nodejs
ynh_nodejs_install
ynh_exec_warn_less "$ynh_npm" install -g configurable-http-proxy
ynh_hide_warnings npm install -g configurable-http-proxy
#=================================================
# SET ADMIN GROUP
#=================================================
ynh_script_progression --message="Adding $admin to $app's group..." --weight=5
ynh_script_progression "Adding $admin to $app's group..."
usermod -a -G "$app" "$admin"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=5
ynh_script_progression "Restoring the app main directory..."
ynh_restore_file --origin_path="$install_dir"
chown -R "$app:$app" "$install_dir"
ynh_restore "$install_dir"
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
ynh_script_progression "Restoring system configurations related to $app..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
ynh_restore "/etc/systemd/system/$app.service"
systemctl enable "$app.service" --quiet
yunohost service add "$app" --description="Console environment for running Python code" --log="/var/log/$app/$app.log"
#=================================================
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
#=================================================
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
ynh_script_progression "Reloading NGINX web server and $app's service..."
ynh_systemd_action --service_name="$app" --action="start" --line_match="JupyterHub is now running at" --log_path="systemd"
ynh_systemctl --service="$app" --action="start" --wait_until="JupyterHub is now running at" --log_path="systemd"
ynh_systemd_action --service_name=nginx --action=reload
ynh_systemctl --service=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app" --last
ynh_script_progression "Restoration completed for $app"

View file

@ -10,36 +10,35 @@ source /usr/share/yunohost/helpers
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping $app's systemd service..." --weight=2
ynh_script_progression "Stopping $app's systemd service..."
ynh_systemd_action --service_name="$app" --action="stop"
ynh_systemctl --service="$app" --action="stop"
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=10
ynh_script_progression "Upgrading dependencies..."
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_use_nodejs
ynh_nodejs_install
ynh_exec_warn_less "$ynh_npm" install -g configurable-http-proxy
ynh_hide_warnings npm install -g configurable-http-proxy
#=================================================
# SET ADMIN GROUP
#=================================================
ynh_script_progression --message="Adding $admin to $app's group..." --weight=5
ynh_script_progression "Adding $admin to $app's group..."
usermod -a -G "$app" "$admin"
#=================================================
# BUILD APP
#=================================================
ynh_script_progression --message="Building app..." --weight=15
ynh_script_progression "Building app..."
ynh_secure_remove --file="$install_dir/.venv"
ynh_safe_rm "$install_dir/.venv"
python3 -m venv "$install_dir/venv"
ynh_exec_warn_less "$install_dir/venv/bin/python3" -m pip install \
ynh_hide_warnings "$install_dir/venv/bin/python3" -m pip install \
jupyterlab=="$(jupyterlab_upstream_version)" \
jupyterhub \
jupyter_collaboration \
@ -51,37 +50,34 @@ ynh_exec_warn_less "$install_dir/venv/bin/python3" -m pip install \
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=1
ynh_script_progression "Updating configuration..."
mkdir -p "$install_dir/config"
path_no_slash=${path%/}
ynh_add_config --template="jupyterhub_config.py" --destination="$install_dir/config/jupyterhub_config.py"
ynh_add_config --template="jupyter_notebook_config.py" --destination="$install_dir/config/jupyter_notebook_config.py"
chown -R "$app:$app" "$install_dir"
ynh_config_add --template="jupyterhub_config.py" --destination="$install_dir/config/jupyterhub_config.py"
ynh_config_add --template="jupyter_notebook_config.py" --destination="$install_dir/config/jupyter_notebook_config.py"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
ynh_script_progression "Upgrading systemd configuration..."
ynh_add_nginx_config
ynh_config_add_nginx
# Create a dedicated systemd config
ynh_add_systemd_config
ynh_config_add_systemd
yunohost service add "$app" --description="Console environment for running Python code" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name="$app" --action="start" --line_match="JupyterHub is now running at" --log_path="systemd"
ynh_systemctl --service="$app" --action="start" --wait_until="JupyterHub is now running at" --log_path="systemd"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last
ynh_script_progression "Upgrade of $app completed"