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

115 lines
4 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-02 20:47:14 +01:00
ynh_systemd_action --action="stop" --service_name="${app}" --log_path="/var/log/$app/$app.log" --line_match="Stopped"
ynh_systemd_action --action="stop" --service_name="${app}_workers" --log_path="systemd" --line_match="Stopped"
2022-04-29 12:18:34 +02:00
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
2022-12-21 16:57:53 +01:00
ynh_script_progression --message="Upgrading source files..." --weight=1
2022-04-29 12:18:34 +02:00
# Download, check integrity, uncompress and patch the source from app.src
2023-02-17 18:52:53 +01:00
ynh_setup_source --dest_dir="$install_dir" --keep=".env"
2022-04-29 12:18:34 +02:00
fi
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-02 20:47:14 +01:00
yunohost service add "${app}"
yunohost service add "${app}_workers"
2022-04-29 12:18:34 +02:00
#=================================================
# START SYSTEMD SERVICE
#=================================================
2022-12-21 16:57:53 +01:00
ynh_script_progression --message="Starting a systemd service..." --weight=1
2022-04-29 12:18:34 +02:00
2023-03-02 20:47:14 +01:00
ynh_systemd_action --service_name="${app}" --action="start" --log_path="/var/log/$app/$app.log" --line_match="Started"
ynh_systemd_action --service_name="${app}_workers" --action="start" --log_path="systemd" --line_match="ready"
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