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

Update install and remove script

This commit is contained in:
Sylvain CECCHETTO 2021-09-30 14:53:52 +02:00
parent 9fa50729ae
commit 8102465e9b
4 changed files with 79 additions and 72 deletions

View file

@ -9,5 +9,5 @@ pkg_dependencies_x86="libavahi-client3 libavahi-common3 libc6 libdbus-1-3 libdvb
pkg_dependencies_rb="libavahi-client3 libavahi-common3 libc6 libdbus-1-3 libdvbcsa1 libpcre2-8-0 libssl1.1 liburiparser1 zlib1g bzip2" pkg_dependencies_rb="libavahi-client3 libavahi-common3 libc6 libdbus-1-3 libdvbcsa1 libpcre2-8-0 libssl1.1 liburiparser1 zlib1g bzip2"
# deb package URLs # deb package URLs
tvheadend_deb_x86_64="https://github.com/YunoHost-Apps/tvheadend_ynh/raw/debs/4.3.1979/tvheadend_4.3-1979%7Eg8fc2dfa7e%7Estretch_amd64.deb" tvheadend_deb_x86="https://github.com/YunoHost-Apps/tvheadend_ynh/raw/debs/4.3.1979/tvheadend_4.3-1979%7Eg8fc2dfa7e%7Estretch_amd64.deb"
tvheadend_deb_arm="https://github.com/YunoHost-Apps/tvheadend_ynh/raw/debs/4.3.1979/tvheadend_4.3-1979%7Eg8fc2dfa7e%7Eraspbianstretch_armhf.deb" tvheadend_deb_arm="https://github.com/YunoHost-Apps/tvheadend_ynh/raw/debs/4.3.1979/tvheadend_4.3-1979%7Eg8fc2dfa7e%7Eraspbianstretch_armhf.deb"

View file

@ -27,7 +27,7 @@ app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#================================================= #=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=2 ynh_script_progression --message="Validating installation parameters..." --weight=1
final_path=/home/hts # Default path for Tvheadend deb package final_path=/home/hts # Default path for Tvheadend deb package
test ! -e "$final_path" || ynh_die --message="The path $final_path already contains a folder" test ! -e "$final_path" || ynh_die --message="The path $final_path already contains a folder"
@ -38,7 +38,7 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
ynh_script_progression --message="Storing installation settings..." --weight=2 ynh_script_progression --message="Storing installation settings..." --weight=1
ynh_app_setting_set --app=$app --key=domain --value=$domain 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=path --value=$path_url
@ -51,20 +51,21 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path
#================================================= #=================================================
# FIND AND OPEN PORTS # FIND AND OPEN PORTS
#================================================= #=================================================
ynh_script_progression --message="Configuring firewall..." --weight=15 ynh_script_progression --message="Finding available ports..." --weight=1
# Find a free port for the web server # Find available ports for web interface and streaming
port=$(ynh_find_port --port=9981) port=$(ynh_find_port --port=9981)
# Open this port
ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port
ynh_app_setting_set --app=$app --key=port --value=$port ynh_app_setting_set --app=$app --key=port --value=$port
# Find a free port for the streaming server
stream_port=$(ynh_find_port --port=9982) stream_port=$(ynh_find_port --port=9982)
# Open this port
ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $stream_port
ynh_app_setting_set --app=$app --key=stream_port --value=$stream_port ynh_app_setting_set --app=$app --key=stream_port --value=$stream_port
# Open ports
ynh_script_progression --message="Configuring firewall..." --weight=15
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 # INSTALL DEPENDENCIES
#================================================= #=================================================
@ -84,16 +85,12 @@ ynh_script_progression --message="Downloading Tvheadend..." --weight=5
temp_folder="$(mktemp -d)" temp_folder="$(mktemp -d)"
tvheadend_deb_dst="$temp_folder/tvheadend_deb.deb" tvheadend_deb_dst="$temp_folder/tvheadend_deb.deb"
tvheadend_deb_url=""
if [ -n "$(uname -m | grep arm)" ] if [ -n "$(uname -m | grep arm)" ]
then then
tvheadend_deb_url="$tvheadend_deb_arm" tvheadend_deb_url="$tvheadend_deb_arm"
elif [ -n "$(uname -m | grep x86_64)" ]
then
tvheadend_deb_url="$tvheadend_deb_x86_64"
else else
tvheadend_deb_url="$tvheadend_deb_x86_32" tvheadend_deb_url="$tvheadend_deb_x86"
fi fi
ynh_exec_quiet "wget -q -O $tvheadend_deb_dst $tvheadend_deb_url" ynh_exec_quiet "wget -q -O $tvheadend_deb_dst $tvheadend_deb_url"
@ -116,20 +113,13 @@ ynh_systemd_action --service_name=$app --action="stop"
#================================================= #=================================================
# MODIFY TVHEADEND CONFIG FILES # MODIFY TVHEADEND CONFIG FILES
#================================================= #=================================================
ynh_script_progression --message="Update configuration files..." --weight=1
# Copy and modify /etc/default/tvheadend # Copy and modify /etc/default/tvheadend
cp ../conf/tvheadend /etc/default/tvheadend ynh_add_config --template="tvheadend" --destination="/etc/default/tvheadend"
ynh_replace_string --match_string="__CONF_DIR__" --replace_string="$final_path/.hts/tvheadend" --target_file="/etc/default/tvheadend"
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="/etc/default/tvheadend"
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 # Copy and modify /home/hts/.hts/tvheadend/superuser
cp ../conf/superuser $final_path/.hts/tvheadend/superuser ynh_add_config --template="superuser" --destination="${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"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
@ -150,9 +140,10 @@ chmod 666 /var/log/$app.log
ynh_use_logrotate --logfile=/var/log/$app.log ynh_use_logrotate --logfile=/var/log/$app.log
#================================================= #=================================================
# ADVERTISE SERVICE IN ADMIN PANEL # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
yunohost service add $app --log "/var/log/$app.log" ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="TV streaming server and recorder" --log "/var/log/$app.log"
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT

View file

@ -31,7 +31,7 @@ stream_port=$(ynh_app_setting_get --app=$app --key=stream_port)
ynh_script_progression --message="Stopping Tvheadend service..." --weight=2 ynh_script_progression --message="Stopping Tvheadend service..." --weight=2
ynh_systemd_action --service_name=$app --action=stop ynh_systemd_action --service_name=$app --action=stop
ynh_exec_quiet systemctl disable $app ynh_exec_quiet systemctl disable $app --quiet
ynh_exec_quiet systemctl daemon-reload ynh_exec_quiet systemctl daemon-reload
#================================================= #=================================================
@ -42,12 +42,19 @@ ynh_script_progression --message="Disable prevent Tvheadend being upgraded throu
apt-mark unhold tvheadend apt-mark unhold tvheadend
#================================================= #=================================================
# REMOVE SERVICE FROM ADMIN PANEL # REMOVE TVHEADEND
#================================================= #=================================================
# Remove a service from the admin panel, added by `yunohost service add` ynh_script_progression --message="Removing Tvheadend..." --weight=6
ynh_package_autopurge $app
#=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#=================================================
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null if ynh_exec_warn_less yunohost service status $app >/dev/null
then then
ynh_script_progression --message="Removing $app service..." --weight=1 ynh_script_progression --message="Removing $app service integration..." --weight=1
yunohost service remove $app yunohost service remove $app
fi fi
@ -65,12 +72,12 @@ ynh_script_progression --message="Removing $app log file..." --weight=1
ynh_secure_remove --file="/var/log/$app.log" ynh_secure_remove --file="/var/log/$app.log"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 ynh_script_progression --message="Removing dependencies..." --weight=3
# Remove the dedicated NGINX config # Remove metapackage and its dependencies
ynh_remove_nginx_config ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE APP MAIN DIR AND CONFIG FILES # REMOVE APP MAIN DIR AND CONFIG FILES
@ -82,30 +89,15 @@ ynh_secure_remove --file="$final_path"
ynh_secure_remove --file="/etc/default/tvheadend" ynh_secure_remove --file="/etc/default/tvheadend"
#================================================= #=================================================
# REMOVE TVHEADEND # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing Tvheadend..." --weight=6 ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
ynh_package_autopurge $app # Remove the dedicated NGINX config
ynh_remove_nginx_config
#================================================= #=================================================
# REMOVE DEDICATED USER # CLOSE PORTS
#=================================================
ynh_script_progression --message="Removing the dedicated hts system user..." --weight=1
# Delete a system user
ynh_system_user_delete --username=hts
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=3
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# CLOSE TVHEADEND PORTS
#================================================= #=================================================
if yunohost firewall list | grep -q "\- $port$" if yunohost firewall list | grep -q "\- $port$"
then then
@ -119,6 +111,14 @@ then
ynh_exec_warn_less yunohost firewall disallow TCP $stream_port ynh_exec_warn_less yunohost firewall disallow TCP $stream_port
fi fi
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated hts system user..." --weight=1
# Delete a system user
ynh_system_user_delete --username=hts
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -20,6 +20,7 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
superuser=$(ynh_app_setting_get --app=$app --key=superuser) superuser=$(ynh_app_setting_get --app=$app --key=superuser)
password=$(ynh_app_setting_get --app=$app --key=password) password=$(ynh_app_setting_get --app=$app --key=password)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
conf_dir=$(ynh_app_setting_get --app=$app --key=conf_dir)
port=$(ynh_app_setting_get --app=$app --key=port) port=$(ynh_app_setting_get --app=$app --key=port)
stream_port=$(ynh_app_setting_get --app=$app --key=stream_port) stream_port=$(ynh_app_setting_get --app=$app --key=stream_port)
@ -51,6 +52,12 @@ ynh_script_progression --message="Stopping Tvheadend service..." --weight=3
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app.log" ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app.log"
#=================================================
# UPGRADE TVHEADEND DEB PACKAGE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
@ -63,11 +70,6 @@ else
ynh_install_app_dependencies $pkg_dependencies_x86 ynh_install_app_dependencies $pkg_dependencies_x86
fi fi
#=================================================
# UPGRADE TVHEADEND DEB PACKAGE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
#================================================= #=================================================
# DOWNLOAD TVHEADEND DEB PACKAGE # DOWNLOAD TVHEADEND DEB PACKAGE
#================================================= #=================================================
@ -104,15 +106,29 @@ then
# we stop it before the configuration # we stop it before the configuration
ynh_systemd_action --service_name=$app --action="stop" ynh_systemd_action --service_name=$app --action="stop"
# Deb install seems to remove the superuser config, let's restore it #=================================================
# RESTORE TVHEADEND CONFIG FILES
#=================================================
ynh_script_progression --message="Restore/update configuration files..." --weight=1
# Copy and modify /etc/default/tvheadend
ynh_add_config --template="tvheadend" --destination="/etc/default/tvheadend"
# Copy and modify /home/hts/.hts/tvheadend/superuser # Copy and modify /home/hts/.hts/tvheadend/superuser
cp ../conf/superuser $final_path/.hts/tvheadend/superuser ynh_add_config --template="superuser" --destination="${conf_dir}/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 fi
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
# Create a dedicated NGINX config
ynh_add_nginx_config
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================