mirror of
https://github.com/YunoHost-Apps/fittrackee_ynh.git
synced 2024-09-03 18:36:16 +02:00
116 lines
4.1 KiB
Bash
116 lines
4.1 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# LOAD SETTINGS
|
|
#=================================================
|
|
|
|
admin_mail=$(ynh_user_get_info --username=$admin --key=username)
|
|
|
|
#=================================================
|
|
# CHECK VERSION
|
|
#=================================================
|
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
|
|
|
#=================================================
|
|
# STANDARD UPGRADE STEPS
|
|
#=================================================
|
|
# STOP SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
|
|
|
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"
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
then
|
|
ynh_script_progression --message="Upgrading source files..." --weight=1
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
ynh_setup_source --dest_dir="$install_dir" --keep=".env"
|
|
fi
|
|
|
|
mkdir -p "$install_dir"
|
|
chmod -R o-rwx "$install_dir"
|
|
chown -R $app: "$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 python-dotenv
|
|
popd
|
|
|
|
#=================================================
|
|
# CONFIGURE THEN INSTALL SCRIPT AND DEPENDENCIES
|
|
#=================================================
|
|
ynh_script_progression --message="Installing service script..." --weight=1
|
|
|
|
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
|
|
|
|
#=================================================
|
|
# Update DATABASE
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading database..." --weight=1
|
|
|
|
ynh_exec_warn_less $install_dir/.venv/bin/ftcli db upgrade
|
|
|
|
|
|
#=================================================
|
|
# NGINX CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
|
|
|
|
# Create a dedicated NGINX config
|
|
ynh_add_nginx_config
|
|
|
|
#=================================================
|
|
# SETUP SYSTEMD
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
|
|
|
|
ynh_add_config --template="../conf/${app}.target" --destination="/etc/systemd/system/$app.target"
|
|
|
|
# Create a dedicated systemd config
|
|
ynh_add_systemd_config --service="${app}" --template="${app}.service"
|
|
ynh_add_systemd_config --service="${app}_workers" --template="${app}_workers.service"
|
|
|
|
|
|
#=================================================
|
|
# GENERIC FINALIZATION
|
|
#=================================================
|
|
# INTEGRATE SERVICE IN YUNOHOST
|
|
#=================================================
|
|
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
|
|
|
yunohost service add "${app}"
|
|
yunohost service add "${app}_workers"
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
|
|
|
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"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|