mirror of
https://github.com/YunoHost-Apps/tvheadend_ynh.git
synced 2024-10-01 13:34:50 +02:00
83 lines
2.9 KiB
Bash
83 lines
2.9 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# STANDARD UPGRADE STEPS
|
|
#=================================================
|
|
# STOP SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Stopping a systemd service..." --weight=3
|
|
|
|
ynh_systemd_action --service_name="$app" --action="stop"
|
|
|
|
#=================================================
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
#=================================================
|
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
|
|
|
if [[ -n "${conf_dir:-}" ]]; then
|
|
# Now we use the standard /var/lib/tvheadend directory
|
|
ynh_secure_remove --file="$data_dir"
|
|
mv "$conf_dir" "$data_dir"
|
|
chown -R "hts:video" "$data_dir"
|
|
|
|
ynh_app_setting_delete --app="$app" --key=conf_dir
|
|
fi
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
ynh_script_progression --message="Installing $app package..." --weight=1
|
|
|
|
chown -R "$app:www-data" "$install_dir"
|
|
|
|
_install_tvheadend_package
|
|
# 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"
|
|
|
|
#=================================================
|
|
# MODIFY TVHEADEND CONFIG FILES
|
|
#=================================================
|
|
ynh_script_progression --message="Update configuration files..." --weight=1
|
|
|
|
# Copy and modify /etc/default/tvheadend
|
|
if [ "$path" = "/" ]; then
|
|
ynh_add_config --template="tvheadend_no_subpath" --destination="/etc/default/tvheadend"
|
|
else
|
|
ynh_add_config --template="tvheadend" --destination="/etc/default/tvheadend"
|
|
fi
|
|
|
|
#=================================================
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
|
|
|
# Create a dedicated NGINX config
|
|
ynh_add_nginx_config
|
|
|
|
yunohost service add "$app" --description="TV streaming server and recorder" --needs_exposed_ports="$port_stream"
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
|
|
|
# Start a systemd service
|
|
ynh_systemd_action --service_name="$app" --action="start"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed, HTSP port is $port_stream" --last
|