mirror of
https://github.com/YunoHost-Apps/fittrackee_ynh.git
synced 2024-09-03 18:36:16 +02:00
128 lines
4.6 KiB
Bash
128 lines
4.6 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# LOAD SETTINGS
|
|
#=================================================
|
|
|
|
admin=$(ynh_user_get_info --username=$admin --key=username)
|
|
admin_mail=$(ynh_user_get_info --username=$admin --key=mail)
|
|
|
|
#=================================================
|
|
# 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}"
|
|
ynh_systemd_action --action="stop" --service_name="${app}_workers"
|
|
|
|
#=================================================
|
|
# INSTALL DEPENDENCIES
|
|
#=================================================
|
|
ynh_script_progression --message="Installing dependencies..." --weight=23
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
chown -R $app: "$install_dir"
|
|
|
|
#=================================================
|
|
# CONFIGURE THE INSTALL SCRIPT
|
|
#=================================================
|
|
ynh_script_progression --message="Installing service script..." --weight=1
|
|
|
|
redis_db=$(ynh_redis_get_free_db)
|
|
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
|
|
|
|
#=================================================
|
|
# INSTALL PYTHON DEPENDENCIES
|
|
#=================================================
|
|
ynh_script_progression --message="Installing Python dependencies..." --weight=3
|
|
|
|
ynh_secure_remove $install_dir/.venv
|
|
|
|
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
|
|
fi
|
|
|
|
pushd $install_dir
|
|
python3 -m venv $install_dir/venv
|
|
source $install_dir/venv/bin/activate
|
|
ynh_exec_warn_less pip install --upgrade pip wheel toml pyyaml
|
|
ynh_exec_warn_less pip install fittrackee==$fittrackee_version
|
|
popd
|
|
|
|
#=================================================
|
|
# 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
|
|
|
|
# Create a dedicated systemd config
|
|
ynh_add_systemd_config --service="${app}" --template="fittrackee.service"
|
|
ynh_add_systemd_config --service="${app}_workers" --template="fittrackee_workers.service"
|
|
|
|
#=================================================
|
|
# GENERIC FINALIZATION
|
|
#=================================================
|
|
# INTEGRATE SERVICE IN YUNOHOST
|
|
#=================================================
|
|
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
|
|
|
yunohost service add "${app}" --description="Fittrackee main service" --log="/var/log/$app/$app.log"
|
|
yunohost service add "${app}_workers" --description="Fittrackee task queue service" --log="var/log/$app/${app}_workers.log"
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Starting the systemd services..." --weight=15
|
|
|
|
# Start a systemd service
|
|
ynh_systemd_action --service_name="${app}" --action="start"
|
|
ynh_systemd_action --service_name="${app}_workers" --action="start"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|