2022-04-29 12:18:34 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2023-12-17 16:52:22 +01:00
|
|
|
#=================================================
|
|
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
|
|
#=================================================
|
2024-06-23 08:56:30 +02:00
|
|
|
ynh_script_progression "Ensuring downward compatibility..."
|
2023-12-17 16:52:22 +01:00
|
|
|
|
2024-06-25 10:58:10 +02:00
|
|
|
ynh_app_setting_set_default --key=weather_provider --value=$weather_api_provider
|
2023-12-17 16:52:22 +01:00
|
|
|
|
2024-06-25 10:58:10 +02:00
|
|
|
ynh_app_setting_set_default --key=weather_key --value=$weather_api_key
|
2023-12-17 16:52:22 +01:00
|
|
|
|
2023-12-17 17:06:42 +01:00
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
admin=$(ynh_user_get_info --username=$admin --key=username)
|
|
|
|
admin_mail=$(ynh_user_get_info --username=$admin --key=mail)
|
|
|
|
|
2022-04-29 12:18:34 +02:00
|
|
|
#=================================================
|
|
|
|
# STOP SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2024-06-23 08:56:30 +02:00
|
|
|
ynh_script_progression "Stopping $app's systemd service..."
|
2022-04-29 12:18:34 +02:00
|
|
|
|
2024-06-23 08:56:30 +02:00
|
|
|
ynh_systemctl --action="stop" --service="${app}"
|
|
|
|
|
|
|
|
ynh_systemctl --action="stop" --service="${app}_workers"
|
2022-04-29 12:18:34 +02:00
|
|
|
|
2023-01-01 00:50:33 +01:00
|
|
|
#=================================================
|
2023-06-11 23:14:27 +02:00
|
|
|
# CONFIGURE THE INSTALL SCRIPT
|
2023-01-01 00:50:33 +01:00
|
|
|
#=================================================
|
2024-06-23 08:56:30 +02:00
|
|
|
ynh_script_progression "Installing service script..."
|
2023-01-01 00:50:33 +01:00
|
|
|
|
2023-09-15 08:57:02 +02:00
|
|
|
redis_db=$(ynh_redis_get_free_db)
|
2024-06-23 08:56:30 +02:00
|
|
|
ynh_config_add --template=".env.production" --destination="$install_dir/.env"
|
2023-03-02 20:47:14 +01:00
|
|
|
|
2023-06-11 23:14:27 +02:00
|
|
|
#=================================================
|
|
|
|
# INSTALL PYTHON DEPENDENCIES
|
|
|
|
#=================================================
|
2024-06-23 08:56:30 +02:00
|
|
|
ynh_script_progression "Installing Python dependencies..."
|
2023-06-11 23:14:27 +02:00
|
|
|
|
2023-08-24 13:53:14 +02:00
|
|
|
if [ $YNH_ARCH == "armhf" ] || [ $YNH_ARCH == "armel" ]
|
|
|
|
then
|
2024-06-23 08:56:30 +02:00
|
|
|
# Install rustup is not already installed
|
2023-08-24 13:53:14 +02:00
|
|
|
# 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
|
2024-06-23 08:56:30 +02:00
|
|
|
ynh_exec_as_app PATH=$PATH rustup update
|
2023-08-24 13:53:14 +02:00
|
|
|
else
|
2024-06-23 08:56:30 +02:00
|
|
|
ynh_exec_as_app bash -c 'curl -sSf -L https://static.rust-lang.org/rustup.sh | sh -s -- -y --default-toolchain=stable --profile=minimal'
|
2023-08-24 13:53:14 +02:00
|
|
|
fi
|
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
|
2024-06-23 08:56:30 +02:00
|
|
|
ynh_hide_warnings pip install --upgrade pip wheel toml pyyaml
|
|
|
|
ynh_hide_warnings pip install fittrackee=="$(ynh_app_upstream_version)"
|
2023-06-12 08:24:20 +02:00
|
|
|
popd
|
2023-06-12 08:49:41 +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
|
|
|
#=================================================
|
2024-06-23 08:56:30 +02:00
|
|
|
ynh_script_progression "Upgrading database..."
|
2023-02-06 00:05:36 +01:00
|
|
|
|
2023-12-26 15:08:30 +01:00
|
|
|
set -a
|
|
|
|
|
|
|
|
source $install_dir/.env
|
|
|
|
|
2024-06-23 08:56:30 +02:00
|
|
|
ynh_hide_warnings $install_dir/venv/bin/ftcli db upgrade
|
2023-01-28 23:42:59 +01:00
|
|
|
|
2023-12-26 15:08:30 +01:00
|
|
|
set +a
|
2022-04-29 12:18:34 +02:00
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
2024-06-23 08:56:30 +02:00
|
|
|
ynh_script_progression "Upgrading NGINX web server configuration..."
|
2022-04-29 12:18:34 +02:00
|
|
|
|
|
|
|
# Create a dedicated NGINX config
|
2024-06-23 08:56:30 +02:00
|
|
|
ynh_config_add_nginx
|
2022-04-29 12:18:34 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SETUP SYSTEMD
|
|
|
|
#=================================================
|
2024-06-23 08:56:30 +02:00
|
|
|
ynh_script_progression "Upgrading systemd configuration..."
|
2022-04-29 12:18:34 +02:00
|
|
|
|
|
|
|
# Create a dedicated systemd config
|
2024-06-23 08:56:30 +02:00
|
|
|
ynh_config_add_systemd --service="${app}" --template="fittrackee.service"
|
|
|
|
ynh_config_add_systemd --service="${app}_workers" --template="fittrackee_workers.service"
|
2023-03-02 20:47:14 +01:00
|
|
|
|
2022-04-29 12:18:34 +02:00
|
|
|
#=================================================
|
|
|
|
# INTEGRATE SERVICE IN YUNOHOST
|
|
|
|
#=================================================
|
2024-06-23 08:56:30 +02:00
|
|
|
ynh_script_progression "Integrating service in YunoHost..."
|
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
|
|
|
|
#=================================================
|
2024-06-23 08:56:30 +02:00
|
|
|
ynh_script_progression "Starting the systemd services..."
|
2022-04-29 12:18:34 +02:00
|
|
|
|
2023-03-06 21:23:33 +01:00
|
|
|
# Start a systemd service
|
2024-06-23 08:56:30 +02:00
|
|
|
ynh_systemctl --service="${app}" --action="start"
|
|
|
|
|
|
|
|
ynh_systemctl --service="${app}_workers" --action="start"
|
2022-04-29 12:18:34 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2024-06-25 10:58:10 +02:00
|
|
|
ynh_script_progression "Upgrade of $app completed"
|