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

141 lines
4.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
#=================================================
2023-04-13 19:51:18 +02:00
admin=$(ynh_user_get_info --username=$admin --key=username)
admin_mail=$(ynh_user_get_info --username=$admin --key=mail)
2023-09-05 14:33:02 +02:00
mail_user=$app
2023-09-05 14:20:19 +02:00
mail_password=$mail_pwd
mail_domain=$domain
2023-09-05 14:07:45 +02:00
2023-02-19 21:27:20 +01:00
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
2023-04-15 08:25:31 +02:00
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=23
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-06-11 23:14:27 +02:00
# CONFIGURE THE INSTALL SCRIPT
#=================================================
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-06-11 23:14:27 +02:00
#=================================================
# INSTALL PYTHON DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing Python dependencies..." --weight=3
2023-06-12 09:54:07 +02:00
ynh_secure_remove $install_dir/.venv
2023-08-24 13:53:14 +02:00
if [ $YNH_ARCH == "armhf" ] || [ $YNH_ARCH == "armel" ]
then
# Install rustup is not already installed
# We need this to be able to install cryptgraphy on ARM hardware
export PATH="$PATH:$install_dir/.cargo/bin:$install_dir/.local/bin:/usr/local/sbin"
if [ -e $install_dir/.rustup ]; then
sudo -u "$app" env PATH=$PATH rustup update
else
sudo -u "$app" bash -c 'curl -sSf -L https://static.rust-lang.org/rustup.sh | sh -s -- -y --default-toolchain=stable --profile=minimal'
fi
2023-08-25 12:12:41 +02:00
sudo -u "$app" env PATH=$PATH rustup install stable
sudo -u "$app" env PATH=$PATH rustup default stable
2023-08-25 11:57:48 +02:00
2023-08-25 11:59:19 +02:00
fi
2023-06-11 23:14:27 +02:00
pushd $install_dir
python3 -m venv $install_dir/venv
source $install_dir/venv/bin/activate
2023-08-25 11:31:49 +02:00
ynh_exec_warn_less pip install --upgrade pip
2023-06-12 08:24:20 +02:00
ynh_exec_warn_less pip install fittrackee==$fittrackee_version toml pyyaml
popd
2023-06-12 08:49:41 +02:00
2023-06-11 23:14:27 +02:00
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-06-11 23:14:27 +02: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-09-04 20:14:01 +02:00
yunohost service add "${app}" --description="Fittrackee main service" --log="/var/log/$app/$app.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