#!/bin/bash set -eu source _common.sh source /usr/share/yunohost/helpers # manage script failure ynh_abort_if_errors # retrieve arguments app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) port=$(ynh_app_setting_get $app port) is_public=$(ynh_app_setting_get $app is_public) # definie useful vars final_path="/srv/$app" data_path="/home/$app/.$app" # use prior backup and restore on error only if backup feature exists on installed instance if [ -f "/etc/yunohost/apps/$app/scripts/backup" ] ; then ynh_backup_before_upgrade # Backup the current version of the app ynh_clean_setup () { ynh_restore_upgradebackup } fi # add required packages ynh_install_app_dependencies "$PKG_DEPENDENCIES" # stop systemd service systemctl stop "$app@$app.service" systemctl disable "$app@$app.service" systemctl --system daemon-reload # upgrade exec_as "$app" -H -s /bin/bash -c " \ echo 'create the virtual environment' \ && python3 -m venv $final_path \ && echo 'activate the virtual environment' \ && source $final_path/bin/activate \ && echo 'install a required python package' \ && python3 -m pip install --upgrade wheel \ && echo 'install Home Assistant' \ && pip3 install --upgrade $app \ " # setup up autostart using systemd ynh_replace_string "__PORT__" "$port" "../conf/$app.service" cp "../conf/$app.service" "/etc/systemd/system/$app@$app.service" # enable & restart systemd service systemctl --system daemon-reload systemctl enable "$app@$app.service" systemctl restart "$app@$app.service" # create a dedicated nginx config ynh_add_nginx_config # reload nginx systemctl reload nginx