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

Merge pull request #15 from YunoHost-Apps/testing

Testing
This commit is contained in:
Salamandar 2024-02-28 17:10:07 +01:00 committed by GitHub
commit e9a4408b68
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 254 additions and 671 deletions

View file

@ -1,5 +1,5 @@
<!--
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/readme_generator
It shall NOT be edited by hand.
-->
@ -18,7 +18,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
TV streaming server and recorder
**Shipped version:** 4.3.2009~ynh10
**Shipped version:** 4.3.2009~ynh11
## Screenshots
@ -44,4 +44,4 @@ or
sudo yunohost app upgrade tvheadend -u https://github.com/YunoHost-Apps/tvheadend_ynh/tree/testing --debug
```
**More info regarding app packaging:** <https://yunohost.org/packaging_apps>
**More info regarding app packaging:** <https://yunohost.org/packaging_apps>

View file

@ -1,5 +1,5 @@
<!--
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/readme_generator
It shall NOT be edited by hand.
-->
@ -18,7 +18,7 @@ Si vous navez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po
Serveur de streaming et d'enregistrement TV
**Version incluse :** 4.3.2009~ynh10
**Version incluse :** 4.3.2009~ynh11
## Captures décran

View file

@ -1,21 +0,0 @@
;; Full test
; Manifest
domain="domain.tld"
path="/path"
superuser="toto"
password="1Strong-Password"
port="9982"
; Checks
pkg_linter=1
setup_sub_dir=1
setup_root=1
setup_nourl=0
setup_private=0
setup_public=0
upgrade=1
# 4.3.1979~ynh9
upgrade=1 from_commit=e82643952e5567db826790e1e4a353559f66f112
backup_restore=1
multi_instance=0
port_already_use=1
change_url=1

View file

@ -1,13 +1,13 @@
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {
proxy_pass http://127.0.0.1:__PORT__;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://127.0.0.1:__PORT__;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
}

View file

@ -3,7 +3,7 @@
# systemd
# See tvheadend --help for more - default "-u hts -g video"
OPTIONS="-u hts -g video -c __CONF_DIR__ --http_port __PORT__ --http_root __PATH__ --htsp_port __STREAM_PORT__"
OPTIONS="-u hts -g video -c __CONF_DIR__ --http_port __PORT__ --http_root __PATH__ --htsp_port __PORT_STREAM__"
# sysvinit
#
@ -58,4 +58,3 @@ TVH_DEBUG=0
# TVH_ARGS
# add any other arguments
TVH_ARGS=""

View file

@ -3,7 +3,7 @@
# systemd
# See tvheadend --help for more - default "-u hts -g video"
OPTIONS="-u hts -g video -c __CONF_DIR__ --http_port __PORT__ --htsp_port __STREAM_PORT__"
OPTIONS="-u hts -g video -c __CONF_DIR__ --http_port __PORT__ --htsp_port __PORT_STREAM__"
# sysvinit
#
@ -58,4 +58,3 @@ TVH_DEBUG=0
# TVH_ARGS
# add any other arguments
TVH_ARGS=""

View file

View file

@ -1,56 +0,0 @@
{
"name": "Tvheadend",
"id": "tvheadend",
"packaging_format": 1,
"description": {
"en": "TV streaming server and recorder",
"fr": "Serveur de streaming et d'enregistrement TV"
},
"version": "4.3.2009~ynh10",
"url": "https://tvheadend.org",
"upstream": {
"license": "GPL-3.0",
"website": "https://tvheadend.org",
"userdoc": "https://tvheadend.org/projects/tvheadend/wiki",
"code": "https://github.com/tvheadend/tvheadend"
},
"license": "GPL-3.0",
"maintainer": {
"name": "Sylvain Cecchetto",
"email": "cecchetto.sylvain@me.com"
},
"requirements": {
"yunohost": ">= 4.3.0"
},
"multi_instance": false,
"services": [
"nginx"
],
"arguments": {
"install" : [
{
"name": "domain",
"type": "domain"
},
{
"name": "path",
"type": "path",
"example": "/tvh",
"default": "/tvh"
},
{
"name": "superuser",
"type": "string",
"ask": {
"en": "Choose the superuser name in order to login on Tvheadend",
"fr": "Choisissez le nom du superutilisateur pour la connexion à Tvheadend"
},
"example": "johndoe"
},
{
"name": "password",
"type": "password"
}
]
}
}

103
manifest.toml Normal file
View file

@ -0,0 +1,103 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
packaging_format = 2
id = "tvheadend"
name = "Tvheadend"
description.en = "TV streaming server and recorder"
description.fr = "Serveur de streaming et d'enregistrement TV"
version = "4.3.2009~ynh11"
maintainers = ["Sylvain Cecchetto"]
[upstream]
license = "GPL-3.0"
website = "https://tvheadend.org"
userdoc = "https://tvheadend.org/projects/tvheadend/wiki"
code = "https://github.com/tvheadend/tvheadend"
[integration]
yunohost = ">= 11.2"
architectures = ["amd64", "armhf"]
multi_instance = false
ldap = "not_relevant"
sso = "not_relevant"
disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ...
ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
[install]
[install.domain]
type = "domain"
[install.path]
type = "path"
default = "/tvh"
[install.init_main_permission]
type = "group"
default = "visitors"
[install.superuser]
ask.en = "Choose the superuser name in order to login on Tvheadend"
ask.fr = "Choisissez le nom du superutilisateur pour la connexion à Tvheadend"
type = "string"
example = "johndoe"
[install.password]
type = "password"
[resources]
[resources.sources.main_bullseye]
amd64.url = "https://dl.cloudsmith.io/public/tvheadend/tvheadend/deb/debian/pool/bullseye/main/t/tv/tvheadend_4.3-2192~gc9b38a81a~bullseye/tvheadend_4.3-2192~gc9b38a81a~bullseye_amd64.deb"
amd64.sha256 = "e8f027620c5af52a805809ff6b42ee321db775f92fb161a6e5875f936f577782"
armhf.url = "https://dl.cloudsmith.io/public/tvheadend/tvheadend/deb/debian/pool/bullseye/main/t/tv/tvheadend_4.3-2192~gc9b38a81a~bullseye/tvheadend_4.3-2192~gc9b38a81a~bullseye_armhf.deb"
armhf.sha256 = "2b34f372c6272e47880555dd67a1aba23b0410d4b69d5aee41483829bcb3ef89"
arm64.url = "https://dl.cloudsmith.io/public/tvheadend/tvheadend/deb/debian/pool/bullseye/main/t/tv/tvheadend_4.3-2192~gc9b38a81a~bullseye/tvheadend_4.3-2192~gc9b38a81a~bullseye_arm64.deb"
arm64.sha256 = "f672912eb67fe3ac9d469c55d87ce2dde097d441413c862eef758e49b140c5a8"
rename = "tvheadend.deb"
format = "whatever"
extract = false
prefetch = false
autoupdate.strategy = "latest_github_tag"
autoupdate.asset = "tarball"
[resources.sources.main_bookworm]
amd64.url = "https://dl.cloudsmith.io/public/tvheadend/tvheadend/deb/debian/pool/bookworm/main/t/tv/tvheadend_4.3-2098~g44bf691ac~bookworm/tvheadend_4.3-2098~g44bf691ac~bookworm_amd64.deb"
amd64.sha256 = "18a95b1d9c0556590a3089f48cf95d851069eaaba2f4066ea52da2b9d27f5920"
rename = "tvheadend.deb"
format = "whatever"
extract = false
prefetch = false
autoupdate.strategy = "latest_github_tag"
autoupdate.asset = "tarball"
[resources.system_user]
[resources.install_dir]
[resources.permissions]
main.url = "/"
[resources.ports]
main.default = 9981
stream.default = 9982
stream.exposed = "TCP"
[resources.apt]
packages = [
"libavahi-client3",
"libavahi-common3",
"libc6",
"libdbus-1-3",
"libdvbcsa1",
"libpcre3",
"libssl1.1",
"libstdc++6",
"liburiparser1",
"zlib1g",
"bzip2",
]

View file

@ -4,18 +4,54 @@
# COMMON VARIABLES
#=================================================
# dependencies used by the app
pkg_dependencies_x86="libavahi-client3 libavahi-common3 libc6 libdbus-1-3 libdvbcsa1 libpcre3 libssl1.1 libstdc++6 liburiparser1 zlib1g bzip2"
pkg_dependencies_rb="libavahi-client3 libavahi-common3 libc6 libdbus-1-3 libdvbcsa1 libpcre2-8-0 libssl1.1 liburiparser1 zlib1g bzip2"
debian=$(lsb_release --codename --short)
pkg_version_bullseye="4.3-2192~gc9b38a81a~bullseye"
pkg_version_bookworm="4.3-2098~g44bf691ac~bookworm"
# deb package URLs
tvheadend_deb_x86="https://github.com/YunoHost-Apps/tvheadend_ynh/raw/debs/4.3.2009/tvheadend_4.3-2009%7Eg1295dd2be%7Estretch_amd64.deb"
tvheadend_deb_arm="https://github.com/YunoHost-Apps/tvheadend_ynh/raw/debs/4.3.2009/tvheadend_4.3-2009%7Eg1295dd2be%7Eraspbianstretch_armhf.deb"
pkg_version_name=pkg_version_$debian
pkg_version="${!pkg_version_name}"
#=================================================
# PERSONAL HELPERS
#=================================================
_install_tvheadend_package() {
# Download the package
if [ ! -f "$install_dir/tvheadend.deb" ]; then
ynh_setup_source --dest_dir="$install_dir" --source_id="main_$debian"
fi
# Pre-seed debconf database with answers of the interactive dpkg
echo tvheadend tvheadend/admin_password password "$password" | debconf-set-selections
echo tvheadend tvheadend/admin_username string "$superuser" | debconf-set-selections
echo tvheadend tvheadend/last_notes note | debconf-set-selections
# Install the package
ynh_package_install \
"$install_dir/tvheadend.deb"
# The doc says it should be called only once,
# but the code says multiple calls are supported.
# Also, they're already installed so that should be quasi instantaneous.
ynh_install_app_dependencies \
tvheadend="$pkg_version"
# Mark packages as dependencies, to allow automatic removal
apt-mark auto tvheadend
# Prevent tvheadend being upgraded through apt…
apt-mark hold tvheadend
}
_uninstall_tvheadend_package() {
apt-mark unhold tvheadend
ynh_package_autopurge tvheadend
# Delete the system user created by the package
deluser hts --remove-home
}
#=================================================
# EXPERIMENTAL HELPERS
#=================================================

View file

@ -10,26 +10,6 @@
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
@ -39,7 +19,7 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup --src_path="$final_path"
ynh_backup --src_path="$install_dir"
#=================================================
# BACKUP THE NGINX CONFIGURATION

View file

@ -9,64 +9,6 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH
new_domain=$YNH_APP_NEW_DOMAIN
new_path=$YNH_APP_NEW_PATH
app=$YNH_APP_INSTANCE_NAME
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
# Needed for helper "ynh_add_nginx_config"
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)
stream_port=$(ynh_app_setting_get --app=$app --key=stream_port)
#=================================================
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_clean_check_starting
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED
#=================================================
change_domain=0
if [ "$old_domain" != "$new_domain" ]
then
change_domain=1
fi
change_path=0
if [ "$old_path" != "$new_path" ]
then
change_path=1
fi
#=================================================
# STANDARD MODIFICATIONS
#=================================================
@ -81,51 +23,16 @@ ynh_systemd_action --service_name=$app --action="stop"
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# Change the path in the NGINX config file
if [ $change_path -eq 1 ]
then
# Make a backup of the original NGINX config file if modified
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for NGINX helper
domain="$old_domain"
path_url="$new_path"
# Create a dedicated NGINX config
ynh_add_nginx_config
# Update Tvheadend configuration file
ynh_script_progression --message="Updating Tvheadend configuration..." --weight=1
if [ "$path_url" = "/" ]
then
ynh_add_config --template="tvheadend_no_subpath" --destination="/etc/default/tvheadend"
else
ynh_add_config --template="tvheadend" --destination="/etc/default/tvheadend"
fi
fi
# Change the domain for NGINX
if [ $change_domain -eq 1 ]
then
# Delete file checksum for the old conf file location
ynh_delete_file_checksum --file="$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
ynh_change_url_nginx_config
#=================================================
# SPECIFIC MODIFICATIONS
#=================================================
# ...
#=================================================
# Update Tvheadend configuration file
if [ $change_path -eq 1 ]
then
if [ "$change_path" -eq 1 ]; then
# Update Tvheadend configuration file
ynh_script_progression --message="Updating Tvheadend configuration..." --weight=1
if [ "$path_url" = "/" ]
then
if [ "$path" = "/" ]; then
ynh_add_config --template="tvheadend_no_subpath" --destination="/etc/default/tvheadend"
else
ynh_add_config --template="tvheadend" --destination="/etc/default/tvheadend"
@ -140,14 +47,7 @@ fi
ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
ynh_systemd_action --service_name="$app" --action="start"
#=================================================
# END OF SCRIPT

View file

@ -10,123 +10,25 @@ source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
# INITIALIZE AND STORE SETTINGS
#=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
# Passwords are not saved by default.
ynh_app_setting_set --app="$app" --key=password --value="$password"
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Downloading and installing $app package..." --weight=1
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
superuser=$YNH_APP_ARG_SUPERUSER
password=$YNH_APP_ARG_PASSWORD
app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1
final_path=/home/hts # Default path for Tvheadend deb package
test ! -e "$final_path" || ynh_die --message="This path $final_path already contains a folder"
# Register (book) web path
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_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
#=================================================
ynh_script_progression --message="Finding available ports..." --weight=1
# Find available ports for web interface and streaming
port=$(ynh_find_port --port=9981)
ynh_app_setting_set --app=$app --key=port --value=$port
stream_port=$(ynh_find_port --port=9982)
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 $stream_port
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=15
if [ -n "$(uname -m | grep arm)" ]
then
ynh_install_app_dependencies $pkg_dependencies_rb
else
ynh_install_app_dependencies $pkg_dependencies_x86
fi
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=2
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# DOWNLOAD TVHEADEND DEB PACKAGE
#=================================================
ynh_script_progression --message="Downloading Tvheadend..." --weight=5
temp_folder="$(mktemp -d)"
tvheadend_deb_dst="$temp_folder/tvheadend_deb.deb"
if [ -n "$(uname -m | grep arm)" ]
then
tvheadend_deb_url="$tvheadend_deb_arm"
else
tvheadend_deb_url="$tvheadend_deb_x86"
fi
ynh_exec_quiet wget -q -O $tvheadend_deb_dst $tvheadend_deb_url
#=================================================
# INSTALL TVHEADEND DEB PACKAGE
#=================================================
ynh_script_progression --message="Installing Tvheadend..." --weight=24
# Pre-seed debconf database with answers of the interactive dpkg
echo tvheadend tvheadend/admin_password password $password | debconf-set-selections
echo tvheadend tvheadend/admin_username string $superuser | debconf-set-selections
echo tvheadend tvheadend/last_notes note | debconf-set-selections
DEBIAN_FRONTEND=noninteractive ynh_exec_warn_less dpkg -i $tvheadend_deb_dst
ynh_secure_remove --file="$temp_folder"
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"
ynh_systemd_action --service_name="$app" --action="stop"
#=================================================
# MODIFY TVHEADEND CONFIG FILES
@ -134,30 +36,23 @@ ynh_systemd_action --service_name=$app --action="stop"
ynh_script_progression --message="Update configuration files..." --weight=1
# Copy and modify /etc/default/tvheadend
conf_dir=$final_path/.hts/tvheadend
ynh_app_setting_set --app=$app --key=conf_dir --value=$conf_dir
if [ "$path_url" = "/" ]
then
ynh_add_config --template="tvheadend_no_subpath" --destination="/etc/default/tvheadend"
conf_dir=$install_dir/.hts/tvheadend
ynh_app_setting_set --app="$app" --key=conf_dir --value="$conf_dir"
if [ "$path" = "/" ]; then
ynh_add_config --template="tvheadend_no_subpath" --destination="/etc/default/tvheadend"
else
ynh_add_config --template="tvheadend" --destination="/etc/default/tvheadend"
ynh_add_config --template="tvheadend" --destination="/etc/default/tvheadend"
fi
#=================================================
# PREVENT TVHEADEND BEING UPGRADED THROUGHT APT
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Prevent Tvheadend being upgraded throught APT..." --weight=1
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
apt-mark hold tvheadend
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="TV streaming server and recorder" --needs_exposed_ports $stream_port
yunohost service add "$app" --description="TV streaming server and recorder" --needs_exposed_ports="$port_stream"
#=================================================
# START SYSTEMD SERVICE
@ -165,24 +60,10 @@ yunohost service add $app --description="TV streaming server and recorder" --nee
ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1
ynh_permission_update --permission="main" --add="visitors"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
ynh_systemd_action --service_name="$app" --action="start"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed, HTSP port is $stream_port" --last
ynh_script_progression --message="Installation of $app completed, HTSP port is $port_stream" --last

View file

@ -9,20 +9,6 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
stream_port=$(ynh_app_setting_get --app=$app --key=stream_port)
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)
#=================================================
# STANDARD REMOVE
#=================================================
@ -30,10 +16,9 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# 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
then
ynh_script_progression --message="Removing $app service integration..." --weight=1
yunohost service remove $app
if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then
ynh_script_progression --message="Removing "$app" service integration..." --weight=1
yunohost service remove "$app"
fi
#=================================================
@ -41,67 +26,27 @@ fi
#=================================================
ynh_script_progression --message="Stopping Tvheadend service..." --weight=2
ynh_systemd_action --service_name=$app --action=stop
ynh_exec_quiet systemctl disable $app --quiet
ynh_systemd_action --service_name="$app" --action=stop
ynh_exec_quiet systemctl disable "$app" --quiet
ynh_exec_quiet systemctl daemon-reload
#=================================================
# UNHOLD TVHEADEND FROM APT
#=================================================
ynh_script_progression --message="Disable prevent Tvheadend being upgraded throught APT..." --weight=2
ynh_script_progression --message="Removing the $app apt package..." --weight=2
apt-mark unhold tvheadend
_uninstall_tvheadend_package
#=================================================
# REMOVE TVHEADEND
# REMOVE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Removing Tvheadend..." --weight=6
ynh_package_autopurge $app
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=3
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# CLOSE A PORT
#=================================================
if yunohost firewall list | grep -q "\- $stream_port$"
then
ynh_script_progression --message="Closing port $stream_port..." --weight=8
ynh_exec_warn_less yunohost firewall disallow TCP $stream_port
fi
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE VARIOUS FILES
#=================================================
ynh_script_progression --message="Removing various files..."
ynh_secure_remove --file="/etc/default/tvheadend"
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
# Delete a system user
deluser hts --remove-home
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -11,108 +11,25 @@ source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
ynh_restore_file --origin_path="$install_dir"
chown -R "$app:www-data" "$install_dir"
#=================================================
# LOAD SETTINGS
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Loading settings..." --weight=1
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)
conf_dir=$(ynh_app_setting_get --app=$app --key=conf_dir)
port=$(ynh_app_setting_get --app=$app --key=port)
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=16
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# OPEN TVHEADEND PORTS
#=================================================
ynh_script_progression --message="Configuring firewall..." --weight=15
if yunohost firewall list | grep -q "\- $stream_port$"
then
ynh_die --message="Port $stream_port already open (and maybe used by another application)"
fi
ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $stream_port
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=7
if [ -n "$(uname -m | grep arm)" ]
then
ynh_install_app_dependencies $pkg_dependencies_rb
else
ynh_install_app_dependencies $pkg_dependencies_x86
fi
#=================================================
# DOWNLOAD TVHEADEND DEB PACKAGE
#=================================================
ynh_script_progression --message="Downloading Tvheadend..." --weight=3
temp_folder="$(mktemp -d)"
tvheadend_deb_dst="$temp_folder/tvheadend_deb.deb"
if [ -n "$(uname -m | grep arm)" ]
then
tvheadend_deb_url="$tvheadend_deb_arm"
else
tvheadend_deb_url="$tvheadend_deb_x86"
fi
ynh_exec_quiet wget -q -O $tvheadend_deb_dst $tvheadend_deb_url
#=================================================
# INSTALL TVHEADEND DEB PACKAGE
#=================================================
ynh_script_progression --message="Installing Tvheadend..." --weight=13
# Pre-seed debconf database with answers of the interactive dpkg
echo tvheadend tvheadend/admin_password password $password | debconf-set-selections
echo tvheadend tvheadend/admin_username string $superuser | debconf-set-selections
echo tvheadend tvheadend/last_notes note | debconf-set-selections
DEBIAN_FRONTEND=noninteractive ynh_exec_warn_less dpkg -i $tvheadend_deb_dst
ynh_secure_remove --file="$temp_folder"
ynh_script_progression --message="Reinstalling $app package..." --weight=1
_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"
ynh_systemd_action --service_name="$app" --action="stop"
#=================================================
# RESTORE TVHEADEND CONFIG FILES
@ -120,35 +37,22 @@ ynh_systemd_action --service_name=$app --action="stop"
ynh_script_progression --message="Restoring Tvheadend main directory and config files..." --weight=1
ynh_restore_file --origin_path="/etc/default/tvheadend"
ynh_restore_file --origin_path="$final_path"
#=================================================
# PREVENT TVHEADEND BEING UPGRADED THROUGHT APT
# RESTORE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Prevent Tvheadend being upgraded throught APT..." --weight=1
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
apt-mark hold tvheadend
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="TV streaming server and recorder" --needs_exposed_ports $stream_port
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
ynh_systemd_action --service_name=$app --action="start"
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name="$app" --action="start"
ynh_systemd_action --service_name=nginx --action=reload
@ -156,4 +60,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app, HTSP port is $stream_port" --last
ynh_script_progression --message="Restoration completed for $app, HTSP port is $port_stream" --last

View file

@ -9,44 +9,6 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
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)
conf_dir=$(ynh_app_setting_get --app=$app --key=conf_dir)
port=$(ynh_app_setting_get --app=$app --key=port)
stream_port=$(ynh_app_setting_get --app=$app --key=stream_port)
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=4
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_clean_check_starting
# 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
#=================================================
@ -54,121 +16,61 @@ ynh_abort_if_errors
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=3
ynh_systemd_action --service_name=$app --action="stop"
ynh_systemd_action --service_name="$app" --action="stop"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Downloading and installing $app package..." --weight=1
ynh_app_setting_delete --app=$app --key=is_public
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
conf_dir=$install_dir/.hts/tvheadend
ynh_app_setting_set --app="$app" --key=conf_dir --value="$conf_dir"
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
#=================================================
# NGINX CONFIGURATION
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# UPGRADE TVHEADEND DEB PACKAGE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=15
if [ -n "$(uname -m | grep arm)" ]
then
ynh_install_app_dependencies $pkg_dependencies_rb
else
ynh_install_app_dependencies $pkg_dependencies_x86
fi
#=================================================
# DOWNLOAD TVHEADEND DEB PACKAGE
#=================================================
ynh_script_progression --message="Downloading Tvheadend..." --weight=5
temp_folder="$(mktemp -d)"
tvheadend_deb_dst="$temp_folder/tvheadend_deb.deb"
if [ -n "$(uname -m | grep arm)" ]
then
tvheadend_deb_url="$tvheadend_deb_arm"
else
tvheadend_deb_url="$tvheadend_deb_x86"
fi
ynh_exec_quiet wget -q -O $tvheadend_deb_dst $tvheadend_deb_url
#=================================================
# INSTALL TVHEADEND DEB PACKAGE
#=================================================
ynh_script_progression --message="Upgrading Tvheadend..." --weight=24
DEBIAN_FRONTEND=noninteractive ynh_exec_warn_less dpkg --force-confold -i $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 TVHEADEND CONFIG FILES
#=================================================
ynh_script_progression --message="Restore/update configuration files..." --weight=1
# Copy and modify /etc/default/tvheadend
if [ "$path_url" = "/" ]
then
ynh_add_config --template="tvheadend_no_subpath" --destination="/etc/default/tvheadend"
else
ynh_add_config --template="tvheadend" --destination="/etc/default/tvheadend"
fi
fi
#=================================================
# PREVENT TVHEADEND BEING UPGRADED THROUGHT APT
#=================================================
apt-mark hold tvheadend
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="TV streaming server and recorder" --needs_exposed_ports $stream_port
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
ynh_systemd_action --service_name=$app --action="start"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
# 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 $stream_port" --last
ynh_script_progression --message="Upgrade of $app completed, HTSP port is $port_stream" --last

11
tests.toml Normal file
View file

@ -0,0 +1,11 @@
test_format = 1.0
[default]
# ------------
# Tests to run
# ------------
args.superuser = "package_checker"
# test_upgrade_from.e82643952e5567db826790e1e4a353559f66f112.name = "4.3.1979~ynh9"