1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/tvheadend_ynh.git synced 2024-10-01 13:34:50 +02:00
tvheadend_ynh/scripts/upgrade

146 lines
5.3 KiB
Text
Raw Normal View History

2019-10-15 15:56:27 +02:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
2019-10-23 10:16:15 +02:00
ynh_script_progression --message="Loading installation settings..." --weight=2
2019-10-15 15:56:27 +02:00
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
2019-10-16 13:19:40 +02:00
path_url=$(ynh_app_setting_get --app=$app --key=path)
2019-10-15 17:33:46 +02:00
superuser=$(ynh_app_setting_get --app=$app --key=superuser)
2019-10-23 10:16:15 +02:00
password=$(ynh_app_setting_get --app=$app --key=password)
2019-10-15 15:56:27 +02:00
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
port=$(ynh_app_setting_get --app=$app --key=port)
stream_port=$(ynh_app_setting_get --app=$app --key=stream_port)
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
2020-10-13 18:23:23 +02:00
ynh_script_progression --message="Backing up Tvheadend before upgrading (may take a while)..." --weight=4
2019-10-15 15:56:27 +02:00
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
2020-10-13 18:23:23 +02:00
ynh_script_progression --message="Stopping Tvheadend service..." --weight=3
2019-10-15 15:56:27 +02:00
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app.log"
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
2019-10-23 10:16:15 +02:00
ynh_script_progression --message="Upgrading dependencies..." --weight=15
2019-10-15 15:56:27 +02:00
if [ -n "$(uname -m | grep arm)" ]
then
ynh_install_app_dependencies $pkg_dependencies_rb
else
ynh_install_app_dependencies $pkg_dependencies_x86
fi
#=================================================
2019-10-23 10:16:15 +02:00
# UPGRADE TVHEADEND DEB PACKAGE
2019-10-15 15:56:27 +02:00
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
2019-10-23 10:16:15 +02:00
#=================================================
# DOWNLOAD TVHEADEND DEB PACKAGE
#=================================================
2020-10-13 18:23:23 +02:00
ynh_script_progression --message="Downloading Tvheadend..." --weight=5
2019-10-15 15:56:27 +02:00
temp_folder="$(mktemp -d)"
tvheadend_deb_dst="$temp_folder/tvheadend_deb.deb"
2019-10-23 10:16:15 +02:00
tvheadend_deb_url=""
2019-10-15 15:56:27 +02:00
if [ -n "$(uname -m | grep arm)" ]
then
2019-10-23 10:16:15 +02:00
tvheadend_deb_url="$tvheadend_deb_arm"
2019-10-15 15:56:27 +02:00
elif [ -n "$(uname -m | grep x86_64)" ]
then
2019-10-23 10:16:15 +02:00
tvheadend_deb_url="$tvheadend_deb_x86_64"
2019-10-15 15:56:27 +02:00
else
2019-10-23 10:16:15 +02:00
tvheadend_deb_url="$tvheadend_deb_x86_32"
2019-10-15 15:56:27 +02:00
fi
2019-10-23 10:16:15 +02:00
ynh_exec_quiet "wget -q -O $tvheadend_deb_dst $tvheadend_deb_url"
#=================================================
# INSTALL TVHEADEND DEB PACKAGE
#=================================================
2020-10-13 18:23:23 +02:00
ynh_script_progression --message="Upgrading Tvheadend..." --weight=24
2019-10-23 10:16:15 +02:00
2021-09-30 13:25:40 +02:00
ynh_exec_warn_less DEBIAN_FRONTEND=noninteractive dpkg --force-confold -i $tvheadend_deb_dst
2019-10-15 15:56:27 +02:00
ynh_secure_remove --file="$temp_folder"
2019-10-23 10:16:15 +02:00
# The deb install automatically create the hts system user
2019-10-15 15:56:27 +02:00
2019-10-23 10:16:15 +02:00
# Tvheadend automatically start after install
# we stop it before the configuration
ynh_systemd_action --service_name=$app --action="stop"
2019-10-23 10:16:15 +02:00
# Deb install seems to remove the superuser config, let's restore it
# Copy and modify /home/hts/.hts/tvheadend/superuser
cp ../conf/superuser $final_path/.hts/tvheadend/superuser
ynh_replace_string --match_string="__SUPERUSER__" --replace_string="$superuser" --target_file="$final_path/.hts/tvheadend/superuser"
ynh_replace_string --match_string="__PASSWORD__" --replace_string="$password" --target_file="$final_path/.hts/tvheadend/superuser"
ynh_store_file_checksum --file="$final_path/.hts/tvheadend/superuser"
2019-10-15 16:25:54 +02:00
2019-10-23 10:16:15 +02:00
fi
2019-10-15 16:25:54 +02:00
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring SSOwat..." --weight=1
ynh_app_setting_set --app=$app --key=skipped_uris --value="/"
2019-10-15 15:56:27 +02:00
#=================================================
# RELOAD NGINX
#=================================================
2020-10-13 18:23:23 +02:00
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
2019-10-15 15:56:27 +02:00
ynh_systemd_action --service_name=nginx --action=reload
2019-10-23 10:16:15 +02:00
#=================================================
# PREVENT TVHEADEND BEING UPGRADED THROUGHT APT
#=================================================
apt-mark hold tvheadend
#=================================================
# START TVHEADEND SERVICE
#=================================================
2020-10-13 18:23:23 +02:00
ynh_script_progression --message="Starting Tvheadend service..." --weight=1
2019-10-23 10:16:15 +02:00
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app.log"
2019-10-15 15:56:27 +02:00
#=================================================
# END OF SCRIPT
#=================================================
2020-10-13 18:23:23 +02:00
ynh_script_progression --message="Upgrade of Tvheadend completed, HTTP port is $port and HTSP port is $stream_port" --last