2022-04-29 12:18:34 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
|
2023-02-27 22:48:27 +01:00
|
|
|
#=================================================
|
|
|
|
# INSTALL DEPENDENCIES
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Installing dependencies..." --weight=23
|
|
|
|
|
|
|
|
ynh_exec_warn_less python3 -m pip install pipenv
|
2023-02-19 21:25:44 +01:00
|
|
|
|
2022-04-29 12:18:34 +02:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2023-02-27 22:48:27 +01:00
|
|
|
ynh_script_progression --message="Setting up source files..." --weight=64
|
2022-04-29 12:18:34 +02:00
|
|
|
|
2023-02-17 18:52:53 +01:00
|
|
|
# Set permissions to app files
|
2023-02-27 22:48:27 +01:00
|
|
|
# mkdir -p "$install_dir/.venv"
|
|
|
|
# chown -R $app:$app "$install_dir"
|
|
|
|
# chmod -R g=u,g-w,o-rwx "$install_dir"
|
|
|
|
# setfacl -nR -m g:$app.main:rx -m d:g:$app.main:rx "$install_dir/.venv"
|
|
|
|
# setfacl -n -m g:$app.main:x "$install_dir"
|
|
|
|
|
|
|
|
# pushd "$install_dir"
|
|
|
|
# sudo -u $app PIPENV_VENV_IN_PROJECT="enabled" PIPENV_SKIP_LOCK=true python3 -m pipenv install jupyterlab==$jupyterlab_version jupyterhub notebook jupyter-server jupyterhub-ldapauthenticator pyzmq sudospawner 2>&1
|
|
|
|
# sudo -u $app python3 -m pipenv run jupyterhub upgrade-db 2>&1
|
|
|
|
# popd
|
|
|
|
|
|
|
|
|
|
|
|
mkdir -p "$install_dir"
|
|
|
|
|
|
|
|
pushd $install_dir
|
|
|
|
mkdir -p .venv
|
|
|
|
PIPENV_VENV_IN_PROJECT="enabled" PIPENV_SKIP_LOCK=true ynh_exec_warn_less python3 -m pipenv install fittrackee==$fittrackee_version
|
|
|
|
popd
|
|
|
|
|
2022-04-29 12:18:34 +02:00
|
|
|
|
2022-12-29 22:41:34 +01:00
|
|
|
#=================================================
|
2023-02-27 22:48:27 +01:00
|
|
|
# CONFIGURE THE INSTALL SCRIPT
|
2022-12-29 22:41:34 +01:00
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Installing service script..." --weight=1
|
|
|
|
|
2023-02-27 22:48:27 +01:00
|
|
|
key=$(ynh_string_random --length=45 | base64)
|
|
|
|
ynh_app_setting_set --app=$app --key=key --value=$key
|
|
|
|
|
|
|
|
|
2023-02-17 18:52:53 +01:00
|
|
|
ynh_add_config --template="../conf/.env.production" --destination="$install_dir/.env"
|
|
|
|
chmod 600 $install_dir/.env
|
|
|
|
chown $app:www-data "$install_dir/.env"
|
2022-12-29 23:14:40 +01:00
|
|
|
|
2023-02-17 18:52:53 +01:00
|
|
|
set -a; source "$install_dir/.env"; set +a
|
2022-12-29 23:14:40 +01:00
|
|
|
|
2023-02-17 18:52:53 +01:00
|
|
|
mkdir "$install_dir/venv"
|
|
|
|
python3 -m venv "$install_dir/venv"
|
2023-02-27 22:48:27 +01:00
|
|
|
source $install_dir/.env
|
2022-04-29 12:18:34 +02:00
|
|
|
|
2022-12-29 23:06:31 +01:00
|
|
|
#=================================================
|
|
|
|
# INITIALIZE DATABASE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Initializing database..." --weight=1
|
|
|
|
|
2023-02-28 11:42:50 +01:00
|
|
|
# $install_dir/venv/ftcli db upgrade
|
2023-02-28 10:09:19 +01:00
|
|
|
|
2023-01-17 21:22:40 +01:00
|
|
|
|
|
|
|
|
2023-01-17 21:56:48 +01:00
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
|
|
|
|
|
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
|
|
|
|
2023-02-27 22:48:27 +01:00
|
|
|
|
2022-04-29 12:18:34 +02:00
|
|
|
#=================================================
|
|
|
|
# SETUP SYSTEMD
|
|
|
|
#=================================================
|
2022-12-12 13:56:12 +01:00
|
|
|
ynh_script_progression --message="Configuring a systemd service..." --weight=1
|
2022-04-29 12:18:34 +02:00
|
|
|
|
|
|
|
# Create a dedicated systemd config
|
2023-02-27 22:48:27 +01:00
|
|
|
ynh_add_systemd_config --service="${app}" --template="${app}.service"
|
2023-02-28 12:29:35 +01:00
|
|
|
ynh_add_systemd_config --service="${app}_workers" --template="${app}_workers.service"
|
2023-02-27 22:48:27 +01:00
|
|
|
|
2022-04-29 12:18:34 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
# INTEGRATE SERVICE IN YUNOHOST
|
|
|
|
#=================================================
|
2022-12-12 13:56:12 +01:00
|
|
|
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
2022-04-29 12:18:34 +02:00
|
|
|
|
2023-02-27 22:48:27 +01:00
|
|
|
yunohost service add "${app}"
|
2023-02-28 12:29:35 +01:00
|
|
|
yunohost service add "${app}_workers"
|
2022-04-29 12:18:34 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2022-12-12 13:56:12 +01:00
|
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
2022-04-29 12:18:34 +02:00
|
|
|
|
|
|
|
# Start a systemd service
|
2023-02-27 22:48:27 +01:00
|
|
|
ynh_systemd_action --service_name="${app}" --action="start" --log_path="systemd" --line_match="Booting worker with pid"
|
2023-02-28 12:29:35 +01:00
|
|
|
ynh_systemd_action --service_name="${app}_workers" --action="start" --log_path="systemd" --line_match="ready"
|
2023-02-27 22:48:27 +01:00
|
|
|
|
2022-04-29 12:18:34 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2022-12-12 13:56:12 +01:00
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|