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

Cleanup, apply template

This commit is contained in:
Salamandar 2024-03-21 23:29:19 +01:00
parent f7577387df
commit a7c9218e63
9 changed files with 303 additions and 324 deletions

View file

@ -108,7 +108,7 @@ c.JupyterHub.authenticator_class = 'ldapauthenticator.LDAPAuthenticator'
## The public facing URL of the whole JupyterHub application.
#
# This is the address on which the proxy will bind. Sets protocol, ip, base_url
c.JupyterHub.bind_url = 'http://:__PORT____PATH__'
c.JupyterHub.bind_url = 'http://:__PORT____PATH_NO_SLASH__'
## Whether to shutdown the proxy when the Hub shuts down.
#

View file

@ -1,3 +1,5 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
packaging_format = 2
id = "jupyterlab"
@ -51,6 +53,14 @@ ram.runtime = "50M"
default = true
[resources]
[resources.sources.main]
url = "https://github.com/jupyterhub/jupyterhub/archive/refs/tags/4.1.0.tar.gz"
sha256 = "2afed4c1cbd7c83d72ad1015a7955bb0f49e82cbe6ba896ee198ecb049b08749"
# Only used for autoupdate, code will checkout the commit
prefetch = false
autoupdate.strategy = "latest_github_tag"
[resources.system_user]
[resources.install_dir]
@ -64,8 +74,14 @@ ram.runtime = "50M"
main.url = "/"
[resources.apt]
packages = "python3-dev, python3-pip, python3-venv"
packages = [
"python3-dev",
"python3-pip",
"python3-venv",
"python3-pipenv",
]
extras.yarn.repo = "deb https://dl.yarnpkg.com/debian/ stable main"
extras.yarn.key = "https://dl.yarnpkg.com/debian/pubkey.gpg"
extras.yarn.packages = "yarn"
[resources.apt.extras.yarn]
repo = "deb https://dl.yarnpkg.com/debian/ stable main"
key = "https://dl.yarnpkg.com/debian/pubkey.gpg"
packages = ["yarn"]

View file

@ -6,12 +6,18 @@
nodejs_version="18"
jupyterlab_version="4.1.0"
#=================================================
# PERSONAL HELPERS
#=================================================
upstream_version() {
upstream_repository=$(ynh_read_manifest --manifest_key='upstream.code')
upstream_url=$(ynh_read_manifest --manifest_key='resources.sources.main.url')
upstream_commit=$(echo "$upstream_url" | sed -e "s|^${upstream_repository}/archive/refs/tags/\(.*\)\.tar\.gz|\1|")
echo "$upstream_commit"
}
jupyterlab_version="$(upstream_version)"
#=================================================
# EXPERIMENTAL HELPERS
#=================================================

View file

@ -1,7 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -22,15 +20,11 @@ ynh_print_info --message="Declaring files to be backed up..."
ynh_backup --src_path="$install_dir"
#=================================================
# BACKUP THE NGINX CONFIGURATION
# BACKUP THE SYSTEM CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP SYSTEMD
#=================================================
ynh_backup --src_path="/etc/systemd/system/$app.service"
#=================================================

View file

@ -1,7 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -9,12 +7,10 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_script_progression --message="Stopping $app's systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
@ -25,26 +21,22 @@ ynh_script_progression --message="Updating NGINX web server configuration..." --
ynh_change_url_nginx_config
#=================================================
# SPECIFIC MODIFICATIONS
#=================================================
# CONFIGURE JUPYTERLAB
#=================================================
domain=$new_domain
path=${new_path%/}
path_no_slash=${new_path%/}
ynh_add_config --template="jupyterhub_config.py" --destination="$install_dir/config/jupyterhub_config.py"
#=================================================
# GENERIC FINALISATION
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
# 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" --line_match="JupyterHub is now running at" --log_path="systemd"
#=================================================
# END OF SCRIPT

View file

@ -1,7 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -12,65 +10,62 @@ source /usr/share/yunohost/helpers
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=15
ynh_script_progression --message="Installing NodeJS..." --weight=15
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_use_nodejs
ynh_exec_warn_less $ynh_npm install -g configurable-http-proxy
python3 -m pip install pipenv
ynh_exec_warn_less "$ynh_npm" install -g configurable-http-proxy
#=================================================
# NGINX CONFIGURATION
# BUILD APP
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
ynh_script_progression --message="Building app..." --weight=5
python3 -m venv "$install_dir/venv"
ynh_exec_warn_less "$install_dir/venv/bin/python3" pip install \
jupyterlab=="$jupyterlab_version" \
jupyterhub \
jupyter_collaboration \
notebook \
jupyterhub-ldapauthenticator \
pyzmq \
jupyterlab-language-pack-fr-FR
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding $app's configuration file..." --weight=1
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 root: "$install_dir"
chown -R "$admin:" "$install_dir/venv"
#=================================================
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
# Create a dedicated systemd config
ynh_add_systemd_config
yunohost service add $app --description="Console environment for running Python code" --log="/var/log/$app/$app.log"
#=================================================
# SPECIFIC SETUP
#=================================================
# BUILD APP
#=================================================
ynh_script_progression --message="Building app..." --weight=5
mkdir -p "$install_dir"
pushd $install_dir
python3 -m venv $install_dir/venv
source $install_dir/venv/bin/activate
ynh_exec_warn_less pip install jupyterlab==$jupyterlab_version jupyterhub jupyter_collaboration notebook jupyterhub-ldapauthenticator pyzmq jupyterlab-language-pack-fr-FR
popd
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
mkdir -p "$install_dir/config"
path=${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 root: $install_dir/
chown -R $admin: $install_dir/venv/
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 a systemd service..." --weight=3
ynh_script_progression --message="Starting $app's 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" --line_match="JupyterHub is now running at" --log_path="systemd"
#=================================================
# END OF SCRIPT

View file

@ -1,7 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -10,17 +8,13 @@ source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST
# REMOVE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
# 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 integration..." --weight=2
yunohost service remove $app
if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then
yunohost service remove "$app"
fi
# Remove the dedicated systemd config

View file

@ -1,7 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -10,6 +8,16 @@
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling NodeJS..." --weight=15
ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version"
ynh_use_nodejs
ynh_exec_warn_less "$ynh_npm" install -g configurable-http-proxy
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
@ -17,19 +25,8 @@ ynh_script_progression --message="Restoring the app main directory..." --weight=
ynh_restore_file --origin_path="$install_dir"
chown -R root: $install_dir/
chown -R $admin: $install_dir/venv/
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=15
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_use_nodejs
$ynh_npm install -g configurable-http-proxy
chown -R root: "$install_dir"
chown -R "$admin:" "$install_dir/venv"
#=================================================
# RESTORE SYSTEMD
@ -39,16 +36,15 @@ ynh_script_progression --message="Restoring system configurations related to $ap
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file --origin_path="/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"
systemctl enable "$app.service" --quiet
yunohost service add "$app" --description="Console environment for running Python code" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=5
ynh_script_progression --message="Reloading NGINX web server and $app's 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" --line_match="JupyterHub is now running at" --log_path="systemd"
ynh_systemd_action --service_name=nginx --action=reload

View file

@ -1,7 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -9,20 +7,12 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=2
ynh_script_progression --message="Stopping $app's systemd service..." --weight=2
ynh_systemd_action --service_name=$app --action="stop"
ynh_systemd_action --service_name="$app" --action="stop"
#=================================================
# UPGRADE DEPENDENCIES
@ -30,29 +20,26 @@ ynh_systemd_action --service_name=$app --action="stop"
ynh_script_progression --message="Upgrading dependencies..." --weight=10
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_use_nodejs
$ynh_npm install -g configurable-http-proxy npm
ynh_exec_warn_less "$ynh_npm" install -g configurable-http-proxy
#=================================================
# SPECIFIC UPGRADE
#=================================================
# BUILD APP
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Building app..." --weight=15
#REMOVEME? ynh_secure_remove $install_dir/.venv
python3 -m venv $install_dir/venv
source $install_dir/venv/bin/activate
ynh_secure_remove --file="$install_dir/.venv"
python3 -m venv "$install_dir/venv"
pushd $install_dir
ynh_exec_warn_less pip install jupyterlab==$jupyterlab_version jupyterhub notebook jupyter_collaboration jupyterhub-ldapauthenticator pyzmq
popd
fi
ynh_exec_warn_less "$install_dir/venv/bin/python3" pip install \
jupyterlab=="$jupyterlab_version" \
jupyterhub \
jupyter_collaboration \
notebook \
jupyterhub-ldapauthenticator \
pyzmq \
jupyterlab-language-pack-fr-FR
#=================================================
# UPDATE A CONFIG FILE
@ -61,32 +48,31 @@ ynh_script_progression --message="Updating a configuration file..." --weight=1
mkdir -p "$install_dir/config"
path=${path%/}
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 root: $install_dir/
chown -R $admin: $install_dir/venv/
chown -R root: "$install_dir"
chown -R "$admin:" "$install_dir/venv"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
# Create a dedicated systemd config
ynh_add_systemd_config
ynh_add_nginx_config
yunohost service add $app --description="Console environment for running Python code" --log="/var/log/$app/$app.log"
# Create a dedicated systemd config
ynh_add_systemd_config
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 a systemd service..." --weight=1
ynh_script_progression --message="Starting $app's 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" --line_match="JupyterHub is now running at" --log_path="systemd"
#=================================================
# END OF SCRIPT