mirror of
https://github.com/YunoHost-Apps/homeassistant_ynh.git
synced 2024-09-03 19:26:16 +02:00
89 lines
3 KiB
Bash
89 lines
3 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
|
|
|
#=================================================
|
|
# STANDARD UPGRADE STEPS
|
|
#=================================================
|
|
# STOP SYSTEMD SERVICE
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Stopping a systemd service..."
|
|
ynh_systemd_action --service_name=$app --action=stop --log_path="/var/log/$app/$app.log"
|
|
|
|
#=================================================
|
|
# "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD, ETC...)
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
then
|
|
ynh_script_progression --message="Upgrading source files..."
|
|
|
|
myynh_install_python --python="$py_required_version"
|
|
myynh_upgrade_venv_directory
|
|
myynh_install_homeassistant
|
|
fi
|
|
|
|
#=================================================
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
|
|
|
ynh_add_nginx_config
|
|
|
|
ynh_add_systemd_config
|
|
|
|
yunohost service add $app --description="Home Assistant server" --log="$log_file"
|
|
|
|
ynh_use_logrotate --logfile="$log_file" --non-append
|
|
|
|
ynh_add_fail2ban_config --logpath="$log_file" --failregex="$failregex"
|
|
|
|
#=================================================
|
|
# RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS, ...)
|
|
#=================================================
|
|
# UPDATE A CONFIG FILE
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Updating a configuration file..."
|
|
cp -r "../conf/homeassistant_conf_files/bin/." "$data_dir/bin/"
|
|
ynh_add_config --template="../conf/sudoers" --destination="/etc/sudoers.d/$app"
|
|
|
|
#=================================================
|
|
# SET FILE OWNERSHIP / PERMISSIONS
|
|
#=================================================
|
|
|
|
myynh_set_permissions
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Starting a systemd service..."
|
|
|
|
# start systemd service with --verbose
|
|
ynh_systemd_action --service_name=$app --action=start --line_match="Home Assistant initialized" --log_path="$log_file" --timeout=3600
|
|
|
|
# remove --verbose from service
|
|
ynh_replace_string --match_string=" --verbose" --replace_string="" --target_file="/etc/systemd/system/$app.service"
|
|
ynh_store_file_checksum --file="/etc/systemd/system/$app.service"
|
|
systemctl daemon-reload
|
|
ynh_systemd_action --service_name=$app --action=restart
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|