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

[+] Code cleanup

This commit is contained in:
Sylvain CECCHETTO 2019-10-23 10:16:15 +02:00
parent 9a9d7cca48
commit 21801fb998
8 changed files with 154 additions and 106 deletions

View file

@ -1,4 +1,4 @@
;; Test complet
;; Full test
; Manifest
domain="domain.tld" (DOMAIN)
path="/path" (PATH)
@ -14,7 +14,8 @@
upgrade=1
backup_restore=1
multi_instance=0
port_already_use=0
incorrect_path=1
port_already_use=1
change_url=1
;;; Levels
# If the level 5 (Package linter) is forced to 1. Please add justifications here.

View file

@ -6,7 +6,7 @@
"en": "Tvheadend is a TV streaming server and recorder for Linux, FreeBSD and Android supporting DVB-S, DVB-S2, DVB-C, DVB-T, ATSC, ISDB-T, IPTV, SAT>IP and HDHomeRun as input sources",
"fr": "Tvheadend est un serveur streaming TV pour Linux et supporte les sources d'entrées DVB-S, DVB-S2, DVB-C, DVB-T, ATSC, ISDB-T, IPTV, SAT>IP et HDHomeRun"
},
"version": "4.2.8-34~ynh3",
"version": "4.2.8-34~ynh4",
"url": "https://tvheadend.org",
"license": "free",
"maintainer": {

View file

@ -25,6 +25,7 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
superuser=$(ynh_app_setting_get --app=$app --key=superuser)
password=$(ynh_app_setting_get --app=$app --key=password)
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)
@ -32,19 +33,19 @@ stream_port=$(ynh_app_setting_get --app=$app --key=stream_port)
#=================================================
# STANDARD BACKUP STEPS
#=================================================
# STOP SYSTEMD SERVICE
# STOP TVHEADEND SERVICE
#=================================================
ynh_script_progression --message="Stopping $app service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app.log"
#=================================================
# BACKUP THE APP MAIN DIR
# BACKUP THE APP MAIN DIR AND CONFIG FILES
#=================================================
ynh_script_progression --message="Backing up $app config..." --weight=4
ynh_script_progression --message="Backing up $app main directory and config files..." --weight=4
ynh_backup --src_path="$final_path"
ynh_backup --src_path="/etc/default/tvheadend"
ynh_backup --src_path="$final_path"
#=================================================
# BACKUP THE NGINX CONFIGURATION
@ -56,14 +57,15 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP LOGROTATE
# BACKUP LOGROTATE AND LOG FILE
#=================================================
ynh_script_progression --message="Backing up logrotate configuration..." --weight=1
ynh_script_progression --message="Backing up logrotate configuration and log file..." --weight=1
ynh_backup --src_path="/etc/logrotate.d/$app"
ynh_backup --src_path="/var/log/$app.log"
#=================================================
# START SYSTEMD SERVICE
# START TVHEADEND SERVICE
#=================================================
ynh_script_progression --message="Starting $app service..." --weight=1
@ -72,6 +74,6 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --time --last
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last

View file

@ -27,6 +27,7 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
superuser=$(ynh_app_setting_get --app=$app --key=superuser)
password=$(ynh_app_setting_get --app=$app --key=password)
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)
@ -49,7 +50,7 @@ fi
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# STOP SYSTEMD SERVICE
# STOP TVHEADEND SERVICE
#=================================================
ynh_script_progression --message="Stopping $app service..." --weight=1
@ -102,13 +103,6 @@ ynh_store_file_checksum --file="/etc/default/tvheadend"
#=================================================
# GENERIC FINALISATION
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting $app service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app.log"
#=================================================
# RELOAD NGINX
#=================================================
@ -116,6 +110,13 @@ ynh_script_progression --message="Reloading nginx web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# START TVHEADEND SERVICE
#=================================================
ynh_script_progression --message="Starting $app service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app.log"
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -30,7 +30,7 @@ app=$YNH_APP_INSTANCE_NAME
ynh_script_progression --message="Validating installation parameters..." --weight=2
final_path=/home/hts # Default path for Tvheadend deb package
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
test ! -e "$final_path" || ynh_die --message="The path $final_path already contains a folder"
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
@ -38,19 +38,20 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..." --weight=1
ynh_script_progression --message="Storing installation settings..." --weight=2
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=superuser --value=$superuser
ynh_app_setting_set --app=$app --key=password --value=$password
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN PORTS (A)
# FIND AND OPEN PORTS
#=================================================
ynh_script_progression --message="Configuring firewall..." --weight=16
ynh_script_progression --message="Configuring firewall..." --weight=15
# Find a free port for the web server
port=$(ynh_find_port --port=9981)
@ -65,9 +66,9 @@ ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $stream_port
ynh_app_setting_set --app=$app --key=stream_port --value=$stream_port
#=================================================
# INSTALL DEPENDENCIES (B)
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=11
ynh_script_progression --message="Installing dependencies..." --weight=15
if [ -n "$(uname -m | grep arm)" ]
then
@ -79,29 +80,35 @@ fi
#=================================================
# DOWNLOAD TVHEADEND DEB PACKAGE
#=================================================
ynh_script_progression --message="Downloading and installing $app..." --weight=51
ynh_script_progression --message="Downloading $app..." --weight=5
temp_folder="$(mktemp -d)"
tvheadend_deb_dst="$temp_folder/tvheadend_deb.deb"
tvheadend_deb_url=""
if [ -n "$(uname -m | grep arm)" ]
then
ynh_exec_quiet "wget -q -O $tvheadend_deb_dst $tvheadend_deb_arm"
tvheadend_deb_url="$tvheadend_deb_arm"
elif [ -n "$(uname -m | grep x86_64)" ]
then
ynh_exec_quiet "wget -q -O $tvheadend_deb_dst $tvheadend_deb_x86_64"
tvheadend_deb_url="$tvheadend_deb_x86_64"
else
ynh_exec_quiet "wget -q -O $tvheadend_deb_dst $tvheadend_deb_x86_32"
tvheadend_deb_url="$tvheadend_deb_x86_32"
fi
# The deb install automatically create the hts system user (C)
ynh_exec_quiet "wget -q -O $tvheadend_deb_dst $tvheadend_deb_url"
#=================================================
# INSTALL TVHEADEND DEB PACKAGE (D)
# INSTALL TVHEADEND DEB PACKAGE
#=================================================
ynh_script_progression --message="Installing $app..." --weight=24
ynh_package_install "$tvheadend_deb_dst"
ynh_secure_remove --file="$temp_folder"
# The deb install automatically create the hts system user
# Tvheadend automatically start after install
# we stop it before the configuration
ynh_systemd_action --service_name=$app --action="stop"
@ -116,21 +123,16 @@ ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_f
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="/etc/default/tvheadend"
ynh_replace_string --match_string="__STREAM_PORT__" --replace_string="$stream_port" --target_file="/etc/default/tvheadend"
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="/etc/default/tvheadend"
ynh_store_file_checksum --file="/etc/default/tvheadend"
# 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"
#=================================================
# STORE CONFIG FILES CHECKSUM
#=================================================
# Calculate and store config files checksum into the app settings
ynh_store_file_checksum --file="/etc/default/tvheadend"
ynh_store_file_checksum --file="$final_path/.hts/tvheadend/superuser"
#=================================================
# NGINX CONFIGURATION (E)
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring nginx web server..." --weight=2
@ -138,7 +140,7 @@ ynh_script_progression --message="Configuring nginx web server..." --weight=2
ynh_add_nginx_config
#=================================================
# SETUP LOGROTATE (F)
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1
@ -148,7 +150,7 @@ chmod 666 /var/log/$app.log
ynh_use_logrotate --logfile=/var/log/$app.log
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL (G)
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
yunohost service add $app --log "/var/log/$app.log"
@ -167,14 +169,14 @@ ynh_script_progression --message="Reloading nginx web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# PREVENT TVHEADEND BEING UPGRADED THROUGHT APT (H)
# PREVENT TVHEADEND BEING UPGRADED THROUGHT APT
#=================================================
ynh_script_progression --message="Prevent $app being upgraded throught APT..." --weight=1
apt-mark hold tvheadend
#=================================================
# START TVHEADEND SERVICE (I)
# START TVHEADEND SERVICE
#=================================================
ynh_script_progression --message="Starting $app service..." --weight=1

View file

@ -18,6 +18,7 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
superuser=$(ynh_app_setting_get --app=$app --key=superuser)
password=$(ynh_app_setting_get --app=$app --key=password)
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)
@ -25,22 +26,23 @@ stream_port=$(ynh_app_setting_get --app=$app --key=stream_port)
#=================================================
# STANDARD REMOVE
#=================================================
# STOP AND REMOVE TVHEADEND SERVICE (I)
# STOP AND DISABLE TVHEADEND SERVICE
#=================================================
ynh_script_progression --message="Stopping $app service..." --weight=1
ynh_script_progression --message="Stopping $app service..." --weight=2
# Remove the dedicated systemd config
ynh_remove_systemd_config
ynh_systemd_action --service_name=$app --action=stop
ynh_exec_quiet systemctl disable $app
ynh_exec_quiet systemctl daemon-reload
#=================================================
# UNHOLD TVHEADEND FROM APT (H)
# UNHOLD TVHEADEND FROM APT
#=================================================
ynh_script_progression --message="Diasble prevent $app being upgraded throught APT..." --weight=1
ynh_script_progression --message="Disable prevent $app being upgraded throught APT..." --weight=2
apt-mark unhold tvheadend
#=================================================
# REMOVE SERVICE FROM ADMIN PANEL (G)
# REMOVE SERVICE FROM ADMIN PANEL
#=================================================
# Remove a service from the admin panel, added by `yunohost service add`
if ynh_exec_warn_less yunohost service status $app >/dev/null
@ -50,7 +52,7 @@ then
fi
#=================================================
# REMOVE LOGROTATE CONFIGURATION (F)
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
@ -63,7 +65,7 @@ ynh_script_progression --message="Removing $app log file..." --weight=1
ynh_secure_remove --file="/var/log/$app.log"
#=================================================
# REMOVE NGINX CONFIGURATION (E)
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing nginx web server configuration..." --weight=1
@ -71,22 +73,23 @@ ynh_script_progression --message="Removing nginx web server configuration..." --
ynh_remove_nginx_config
#=================================================
# REMOVE TVHEADEND (D)
# REMOVE APP MAIN DIR AND CONFIG FILES
#=================================================
ynh_script_progression --message="Removing $app..." --weight=5
ynh_script_progression --message="Removing $app main directory and config files..." --weight=2
# Remove the app directory securely (/home/hts folder)
ynh_secure_remove --file="$final_path"
ynh_secure_remove --file="/etc/default/tvheadend"
#=================================================
# REMOVE TVHEADEND
#=================================================
ynh_script_progression --message="Removing $app..." --weight=6
ynh_package_autopurge $app
#=================================================
# REMOVE APP MAIN DIR (C)
#=================================================
ynh_script_progression --message="Removing $app main directory..." --weight=1
# Remove the app directory securely (/home/hts folder)
ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE DEDICATED USER (C)
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated hts system user..." --weight=1
@ -94,7 +97,7 @@ ynh_script_progression --message="Removing the dedicated hts system user..." --w
ynh_system_user_delete --username=hts
#=================================================
# REMOVE DEPENDENCIES (B)
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=3
@ -102,22 +105,22 @@ ynh_script_progression --message="Removing dependencies..." --weight=3
ynh_remove_app_dependencies
#=================================================
# CLOSE TVHEADEND PORTS (A)
# CLOSE TVHEADEND PORTS
#=================================================
if yunohost firewall list | grep -q "\- $port$"
then
ynh_script_progression --message="Closing port $port..." --weight=4
ynh_script_progression --message="Closing port $port..." --weight=8
ynh_exec_warn_less yunohost firewall disallow TCP $port
fi
if yunohost firewall list | grep -q "\- $stream_port$"
then
ynh_script_progression --message="Closing port $stream_port..." --weight=4
ynh_script_progression --message="Closing port $stream_port..." --weight=8
ynh_exec_warn_less yunohost firewall disallow TCP $stream_port
fi
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed" --time --last
ynh_script_progression --message="Removal of $app completed" --last

View file

@ -24,6 +24,7 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
superuser=$(ynh_app_setting_get --app=$app --key=superuser)
password=$(ynh_app_setting_get --app=$app --key=password)
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)
@ -31,7 +32,7 @@ stream_port=$(ynh_app_setting_get --app=$app --key=stream_port)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1
ynh_script_progression --message="Validating restoration parameters..." --weight=16
ynh_webpath_available --domain=$domain --path_url=$path_url \
|| ynh_die --message="Path not available: ${domain}${path_url}"
@ -39,7 +40,9 @@ test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#=================================================
# OPEN TVHEADEND PORTS (A)
# STANDARD MODIFICATIONS
#=================================================
# OPEN TVHEADEND PORTS
#=================================================
if yunohost firewall list | grep -q "\- $port$"
then
@ -55,9 +58,9 @@ ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port
ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $stream_port
#=================================================
# INSTALL DEPENDENCIES (B)
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=11
ynh_script_progression --message="Installing dependencies..." --weight=7
if [ -n "$(uname -m | grep arm)" ]
then
@ -69,53 +72,64 @@ fi
#=================================================
# DOWNLOAD TVHEADEND DEB PACKAGE
#=================================================
ynh_script_progression --message="Downloading and installing $app..." --weight=51
ynh_script_progression --message="Downloading $app..." --weight=3
temp_folder="$(mktemp -d)"
tvheadend_deb_dst="$temp_folder/tvheadend_deb.deb"
tvheadend_deb_url=""
if [ -n "$(uname -m | grep arm)" ]
then
ynh_exec_quiet "wget -q -O $tvheadend_deb_dst $tvheadend_deb_arm"
tvheadend_deb_url="$tvheadend_deb_arm"
elif [ -n "$(uname -m | grep x86_64)" ]
then
ynh_exec_quiet "wget -q -O $tvheadend_deb_dst $tvheadend_deb_x86_64"
tvheadend_deb_url="$tvheadend_deb_x86_64"
else
ynh_exec_quiet "wget -q -O $tvheadend_deb_dst $tvheadend_deb_x86_32"
tvheadend_deb_url="$tvheadend_deb_x86_32"
fi
# The deb install automatically create the hts system user (C)
ynh_exec_quiet "wget -q -O $tvheadend_deb_dst $tvheadend_deb_url"
#=================================================
# INSTALL TVHEADEND DEB PACKAGE (D)
# INSTALL TVHEADEND DEB PACKAGE
#=================================================
ynh_script_progression --message="Installing $app..." --weight=13
ynh_package_install "$tvheadend_deb_dst"
ynh_secure_remove --file="$temp_folder"
# The deb install automatically create the hts system user
# Tvheadend automatically start after install
# we stop it before the configuration
ynh_systemd_action --service_name=$app --action="stop"
#=================================================
# RESTORE THE APP CONFIG FILES
# RESTORE TVHEADEND CONFIG FILES
#=================================================
ynh_script_progression --message="Restoring $app config..." --weight=2
ynh_script_progression --message="Restoring $app main directory and config files..." --weight=1
ynh_restore_file --origin_path="$final_path"
ynh_restore_file --origin_path="/etc/default/tvheadend"
ynh_restore_file --origin_path="$final_path"
#=================================================
# RESTORE THE NGINX CONFIGURATION (E)
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring nginx web server configuration..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION (F)
# RESTORE THE LOGROTATE CONFIGURATION AND LOG FILE
#=================================================
ynh_script_progression --message="Restoring logrotate configuration and log file..." --weight=1
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
ynh_restore_file --origin_path="/var/log/$app.log"
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL (G)
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
yunohost service add $app --log "/var/log/$app.log"
@ -134,14 +148,14 @@ ynh_script_progression --message="Reloading nginx web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# PREVENT TVHEADEND BEING UPGRADED THROUGHT APT (G)
# PREVENT TVHEADEND BEING UPGRADED THROUGHT APT
#=================================================
ynh_script_progression --message="Prevent $app being upgraded throught APT..." --weight=1
apt-mark hold tvheadend
#=================================================
# START TVHEADEND SERVICE (I)
# START TVHEADEND SERVICE
#=================================================
ynh_script_progression --message="Starting $app service..." --weight=1

View file

@ -11,13 +11,14 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
ynh_script_progression --message="Loading installation settings..." --weight=2
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
superuser=$(ynh_app_setting_get --app=$app --key=superuser)
password=$(ynh_app_setting_get --app=$app --key=password)
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)
@ -46,14 +47,14 @@ ynh_abort_if_errors
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping $app service..." --weight=1
ynh_script_progression --message="Stopping $app service..." --weight=3
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app.log"
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=11
ynh_script_progression --message="Upgrading dependencies..." --weight=15
if [ -n "$(uname -m | grep arm)" ]
then
@ -63,43 +64,55 @@ else
fi
#=================================================
# INSTALL DEB PACKAGE
# UPGRADE TVHEADEND DEB PACKAGE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading $app..." --weight=51
#=================================================
# DOWNLOAD TVHEADEND DEB PACKAGE
#=================================================
ynh_script_progression --message="Downloading $app..." --weight=5
temp_folder="$(mktemp -d)"
tvheadend_deb_dst="$temp_folder/tvheadend_deb.deb"
tvheadend_deb_url=""
if [ -n "$(uname -m | grep arm)" ]
then
ynh_exec_quiet "wget -q -O $tvheadend_deb_dst $tvheadend_deb_arm"
tvheadend_deb_url="$tvheadend_deb_arm"
elif [ -n "$(uname -m | grep x86_64)" ]
then
ynh_exec_quiet "wget -q -O $tvheadend_deb_dst $tvheadend_deb_x86_64"
tvheadend_deb_url="$tvheadend_deb_x86_64"
else
ynh_exec_quiet "wget -q -O $tvheadend_deb_dst $tvheadend_deb_x86_32"
tvheadend_deb_url="$tvheadend_deb_x86_32"
fi
ynh_exec_quiet "wget -q -O $tvheadend_deb_dst $tvheadend_deb_url"
#=================================================
# INSTALL TVHEADEND DEB PACKAGE
#=================================================
ynh_script_progression --message="Upgrading $app..." --weight=24
ynh_package_install "$tvheadend_deb_dst"
ynh_secure_remove --file="$temp_folder"
# The deb install automatically create the hts system user
# Tvheadend automatically start after install
# we stop it before the configuration
ynh_systemd_action --service_name=$app --action="stop"
# 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"
fi
#=================================================
# PREVENT TVHEADEND BEING UPGRADED THROUGHT APT
#=================================================
apt-mark hold tvheadend
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting $app service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app.log"
#=================================================
# SETUP SSOWAT
#=================================================
@ -114,6 +127,18 @@ ynh_script_progression --message="Reloading nginx web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# PREVENT TVHEADEND BEING UPGRADED THROUGHT APT
#=================================================
apt-mark hold tvheadend
#=================================================
# START TVHEADEND SERVICE
#=================================================
ynh_script_progression --message="Starting $app service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app.log"
#=================================================
# END OF SCRIPT
#=================================================