#!/bin/bash source _common.sh source /usr/share/yunohost/helpers #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= ynh_script_progression "Ensuring downward compatibility..." ynh_app_setting_set_default --key=weather_provider --value=$weather_api_provider ynh_app_setting_set_default --key=weather_key --value=$weather_api_key #================================================= # LOAD SETTINGS #================================================= admin=$(ynh_user_get_info --username=$admin --key=username) admin_mail=$(ynh_user_get_info --username=$admin --key=mail) #================================================= # STOP SYSTEMD SERVICE #================================================= ynh_script_progression "Stopping $app's systemd service..." ynh_systemctl --action="stop" --service="${app}" ynh_systemctl --action="stop" --service="${app}_workers" #================================================= # CONFIGURE THE INSTALL SCRIPT #================================================= ynh_script_progression "Installing service script..." redis_db=$(ynh_redis_get_free_db) ynh_config_add --template=".env.production" --destination="$install_dir/.env" #================================================= # INSTALL PYTHON DEPENDENCIES #================================================= ynh_script_progression "Installing Python dependencies..." 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 ynh_exec_as_app PATH=$PATH rustup update else ynh_exec_as_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_hide_warnings pip install --upgrade pip wheel toml pyyaml ynh_hide_warnings pip install fittrackee=="$(ynh_app_upstream_version)" popd #================================================= # Update DATABASE #================================================= ynh_script_progression "Upgrading database..." set -a source $install_dir/.env ynh_hide_warnings $install_dir/venv/bin/ftcli db upgrade set +a #================================================= # NGINX CONFIGURATION #================================================= ynh_script_progression "Upgrading NGINX web server configuration..." # Create a dedicated NGINX config ynh_config_add_nginx #================================================= # SETUP SYSTEMD #================================================= ynh_script_progression "Upgrading systemd configuration..." # Create a dedicated systemd config ynh_config_add_systemd --service="${app}" --template="fittrackee.service" ynh_config_add_systemd --service="${app}_workers" --template="fittrackee_workers.service" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression "Integrating service in YunoHost..." 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 "Starting the systemd services..." # Start a systemd service ynh_systemctl --service="${app}" --action="start" ynh_systemctl --service="${app}_workers" --action="start" #================================================= # END OF SCRIPT #================================================= ynh_script_progression "Upgrade of $app completed"