1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/fittrackee_ynh.git synced 2024-09-03 18:36:16 +02:00
fittrackee_ynh/scripts/upgrade

109 lines
3.8 KiB
Text
Raw Normal View History

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-19 21:27:20 +01:00
#=================================================
# LOAD SETTINGS
#=================================================
admin_mail=$(ynh_user_get_info --username=$admin --key=username)
2022-04-29 12:18:34 +02:00
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
2022-12-21 16:57:53 +01:00
ynh_script_progression --message="Stopping a systemd service..." --weight=1
2022-04-29 12:18:34 +02:00
2023-03-09 13:38:15 +01:00
ynh_systemd_action --action="stop" --service_name="${app}"
ynh_systemd_action --action="stop" --service_name="${app}_workers"
2022-04-29 12:18:34 +02:00
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
2023-03-02 20:47:14 +01:00
mkdir -p "$install_dir"
2023-02-17 18:52:53 +01:00
chmod -R o-rwx "$install_dir"
2023-03-02 20:47:14 +01:00
chown -R $app: "$install_dir"
2022-04-29 12:18:34 +02:00
2023-03-02 20:47:14 +01:00
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 python-dotenv
popd
2023-02-06 11:17:52 +01:00
#=================================================
# CONFIGURE THEN INSTALL SCRIPT AND DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing service script..." --weight=1
2023-03-02 20:47:14 +01:00
ynh_add_config --template="../conf/.env.production" --destination="$install_dir/.env"
chmod 600 $install_dir/.env
chown $app: "$install_dir/.env"
set -a; source "$install_dir/.env"; set +a
2023-02-06 00:05:36 +01:00
#=================================================
2023-02-06 01:58:53 +01:00
# Update DATABASE
2023-02-06 00:05:36 +01:00
#=================================================
2023-02-06 01:58:53 +01:00
ynh_script_progression --message="Upgrading database..." --weight=1
2023-02-06 00:05:36 +01:00
2023-03-02 20:47:14 +01:00
ynh_exec_warn_less $install_dir/.venv/bin/ftcli db upgrade
2023-01-28 23:42:59 +01:00
2023-01-18 09:27:54 +01:00
2022-04-29 12:18:34 +02:00
#=================================================
# NGINX CONFIGURATION
#=================================================
2022-12-21 16:57:53 +01:00
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
2022-04-29 12:18:34 +02:00
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SETUP SYSTEMD
#=================================================
2022-12-21 17:12:48 +01:00
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
2022-04-29 12:18:34 +02:00
# Create a dedicated systemd config
2023-03-02 21:56:14 +01:00
ynh_add_systemd_config --service="${app}" --template="fittrackee.service"
ynh_add_systemd_config --service="${app}_workers" --template="fittrackee_workers.service"
2023-03-02 20:47:14 +01:00
2022-04-29 12:18:34 +02:00
#=================================================
# GENERIC FINALIZATION
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
2022-12-21 16:57:53 +01:00
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
2022-04-29 12:18:34 +02:00
2023-03-09 13:38:15 +01:00
yunohost service add "${app}" --description="Fittrackee main service" --log="/var/log/$app/$app.log" --log="/var/log/$app/gunicorn.log"
2023-03-08 21:40:21 +01:00
yunohost service add "${app}_workers" --description="Fittrackee task queue service" --log="var/log/$app/${app}_workers.log"
2022-04-29 12:18:34 +02:00
#=================================================
# START SYSTEMD SERVICE
#=================================================
2023-03-06 21:23:33 +01:00
ynh_script_progression --message="Starting the systemd services..." --weight=15
2022-04-29 12:18:34 +02:00
2023-03-06 21:23:33 +01:00
# Start a systemd service
2023-03-09 13:38:15 +01:00
ynh_systemd_action --service_name="${app}" --action="start"
ynh_systemd_action --service_name="${app}_workers" --action="start"
2022-04-29 12:18:34 +02:00
#=================================================
# END OF SCRIPT
#=================================================
2022-12-21 16:57:53 +01:00
ynh_script_progression --message="Upgrade of $app completed" --last