diff --git a/README.md b/README.md index 68308ae..f00d875 100644 --- a/README.md +++ b/README.md @@ -1,55 +1,41 @@ + + # Tvheadend for YunoHost [![Integration level](https://dash.yunohost.org/integration/tvheadend.svg)](https://dash.yunohost.org/appci/app/tvheadend) ![](https://ci-apps.yunohost.org/ci/badges/tvheadend.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/tvheadend.maintain.svg) -[![Install tvheadend with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=tvheadend) +[![Install Tvheadend with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=tvheadend) *[Lire ce readme en français.](./README_fr.md)* -> *This package allow you to install Tvheadend quickly and simply on a YunoHost server. -If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* +> *This package allows you to install Tvheadend quickly and simply on a YunoHost server. +If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.* ## Overview -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. -Tvheadend offers the HTTP (VLC, MPlayer), HTSP (Kodi, Movian) and SAT>IP streaming. +TV streaming server and recorder -Multiple EPG sources are supported (over-the-air DVB and ATSC including OpenTV DVB extensions, XMLTV, PyXML). +**Shipped version:** 4.3.1979~ynh6 -Tvheadend works as backend PVR live TV for Kodi. -**Shipped version:** 4.2.8-36 ## Screenshots -![](http://docs.tvheadend.org/images/overall_screenshot.png) +![](./doc/screenshots/overall_screenshot.png) -## Configuration +## Documentation and resources -Once the Tvheadend package is installed, go to the chosen URL, login with the superuser credentials and follow the setup wizard. +* Official app website: https://tvheadend.org +* Official user documentation: https://tvheadend.org/projects/tvheadend/wiki +* Upstream app code repository: https://github.com/tvheadend/tvheadend +* YunoHost documentation for this app: https://yunohost.org/app_tvheadend +* Report a bug: https://github.com/YunoHost-Apps/tvheadend_ynh/issues -## Documentation +## Developer info - * Official documentation: http://docs.tvheadend.org - -## YunoHost specific features - -#### Supported architectures - -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/tvheadend%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/tvheadend/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/tvheadend%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/tvheadend/) - -## Links - - * Report a bug: https://github.com/YunoHost-Apps/tvheadend_ynh/issues - * App website: https://tvheadend.org - * Upstream app repository: https://github.com/tvheadend/tvheadend - * YunoHost website: https://yunohost.org/ - ---- - -## Developers info - -Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/tvheadend_ynh/tree/testing). +Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/tvheadend_ynh/tree/testing). To try the testing branch, please proceed like that. ``` @@ -57,3 +43,5 @@ sudo yunohost app install https://github.com/YunoHost-Apps/tvheadend_ynh/tree/te 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 \ No newline at end of file diff --git a/README_fr.md b/README_fr.md index 55547b5..81ed08e 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,52 +1,33 @@ # Tvheadend pour YunoHost -[![Integration level](https://dash.yunohost.org/integration/tvheadend.svg)](https://dash.yunohost.org/appci/app/tvheadend) ![](https://ci-apps.yunohost.org/ci/badges/tvheadend.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/tvheadend.maintain.svg) -[![Install tvheadend with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=tvheadend) +[![Niveau d'intégration](https://dash.yunohost.org/integration/tvheadend.svg)](https://dash.yunohost.org/appci/app/tvheadend) ![](https://ci-apps.yunohost.org/ci/badges/tvheadend.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/tvheadend.maintain.svg) +[![Installer Tvheadend avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=tvheadend) -*[Read this readme in english.](./README.md)* +*[Read this readme in english.](./README.md)* +*[Lire ce readme en français.](./README_fr.md)* -> *Ce package vous permet d'installer Tvheadend rapidement et simplement sur un serveur YunoHost. +> *Ce package vous permet d'installer Tvheadend rapidement et simplement sur un serveur YunoHost. Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.* ## Vue d'ensemble -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. -Tvheadend offers the HTTP (VLC, MPlayer), HTSP (Kodi, Movian) and SAT>IP streaming. +Serveur de streaming et d'enregistrement TV -Multiple EPG sources are supported (over-the-air DVB and ATSC including OpenTV DVB extensions, XMLTV, PyXML). +**Version incluse :** 4.3.1979~ynh6 -Tvheadend works as backend PVR live TV for Kodi. -**Version incluse:** 4.2.8-36 ## Captures d'écran -![](http://docs.tvheadend.org/images/overall_screenshot.png) +![](./doc/screenshots/overall_screenshot.png) -## Configuration +## Documentations et ressources -Une fois le paquet Tvheadend installé, allez à l'URL choisie, connectez-vous avec l'identification du superuser et suivez les instructions de l'assistant de configuration. - -## Documentation - - * Documentation officielle : http://docs.tvheadend.org - -## Caractéristiques spécifiques YunoHost - -#### Architectures supportées - -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/tvheadend%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/tvheadend/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/tvheadend%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/tvheadend/) - - -## Liens - - * Signaler un bug: https://github.com/YunoHost-Apps/tvheadend_ynh/issues - * Site de l'application: https://tvheadend.org - * Dépôt de l'application principale: https://github.com/tvheadend/tvheadend - * Site web YunoHost: https://yunohost.org/ - ---- +* Site officiel de l'app : https://tvheadend.org +* Documentation officielle utilisateur : https://tvheadend.org/projects/tvheadend/wiki +* Dépôt de code officiel de l'app : https://github.com/tvheadend/tvheadend +* Documentation YunoHost pour cette app : https://yunohost.org/app_tvheadend +* Signaler un bug : https://github.com/YunoHost-Apps/tvheadend_ynh/issues ## Informations pour les développeurs @@ -58,3 +39,5 @@ sudo yunohost app install https://github.com/YunoHost-Apps/tvheadend_ynh/tree/te ou sudo yunohost app upgrade tvheadend -u https://github.com/YunoHost-Apps/tvheadend_ynh/tree/testing --debug ``` + +**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps \ No newline at end of file diff --git a/check_process b/check_process index e35316d..8312e45 100644 --- a/check_process +++ b/check_process @@ -1,30 +1,16 @@ ;; Full test ; Manifest - domain="domain.tld" (DOMAIN) - path="/path" (PATH) - superuser="toto" - password="pass" + superuser="toto" + password="865t5cTNjU8wPpY6" ; Checks pkg_linter=1 - setup_sub_dir=1 setup_root=1 + setup_sub_dir=1 setup_nourl=0 - setup_private=0 - setup_public=1 upgrade=1 backup_restore=1 multi_instance=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. - Level 5=auto -;;; Options -Email= -Notification=none -;;; Upgrade options - ; commit=CommitHash - name=Name and date of the commit. - manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666& - + actions=0 + config_panel=0 diff --git a/conf/nginx.conf b/conf/nginx.conf index dd47ac2..b6db808 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,8 +1,4 @@ -#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; -location __PATH__/ { - # Path to source - alias __FINALPATH__/ ; - +location __PATH__ { # Force usage of https if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; diff --git a/conf/superuser b/conf/superuser deleted file mode 100644 index 6a9f663..0000000 --- a/conf/superuser +++ /dev/null @@ -1,4 +0,0 @@ -{ -"username": "__SUPERUSER__", -"password": "__PASSWORD__" -} \ No newline at end of file diff --git a/conf/tvheadend b/conf/tvheadend index 1e06f87..eb6926a 100644 --- a/conf/tvheadend +++ b/conf/tvheadend @@ -3,7 +3,7 @@ # systemd # See tvheadend --help for more - default "-u hts -g video" -OPTIONS="-u hts -g video" +OPTIONS="-u hts -g video -c __CONF_DIR__ --http_port __PORT__ --http_root __PATH__ --htsp_port __STREAM_PORT__" # sysvinit # @@ -24,7 +24,7 @@ TVH_GROUP="video" # TVH_CONF_DIR # if set to "" will use ~TVH_USER/.hts/tvheadend -TVH_CONF_DIR="__CONF_DIR__" +TVH_CONF_DIR="" # TVH_ADAPTERS # if set to "" will use all available adapters @@ -39,17 +39,17 @@ TVH_IPV6=0 # TVH_HTTP_PORT # if set to "" will use binary default -TVH_HTTP_PORT="__PORT__" +TVH_HTTP_PORT="" # TVH_HTTP_ROOT # if set to "" will use binary default # else will change the webui root context, useful for proxied # servers -TVH_HTTP_ROOT="__PATH__" +TVH_HTTP_ROOT="" # TVH_HTSP_PORT # if set to "" will use binary default -TVH_HTSP_PORT="__STREAM_PORT__" +TVH_HTSP_PORT="" # TVH_DEBUG # if set to 1 will output debug to syslog @@ -57,5 +57,5 @@ TVH_DEBUG=0 # TVH_ARGS # add any other arguments -TVH_ARGS="-l /var/log/__APP__.log" +TVH_ARGS="" diff --git a/conf/tvheadend_no_subpath b/conf/tvheadend_no_subpath new file mode 100644 index 0000000..592fc1e --- /dev/null +++ b/conf/tvheadend_no_subpath @@ -0,0 +1,61 @@ +# +# Default configuration for tvheadend + +# 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__" + +# sysvinit +# +# Editing the following variables has no effect when using systemd +# modify the OPTIONS variable (above) instead. +# +# TVH_ENABLED +# set to 0 to disable upstart job +TVH_ENABLED=1 + +# TVH_USER +# if set to "" will run as root +TVH_USER="hts" + +# TVH_GROUP +# if set to "" will run as root +TVH_GROUP="video" + +# TVH_CONF_DIR +# if set to "" will use ~TVH_USER/.hts/tvheadend +TVH_CONF_DIR="" + +# TVH_ADAPTERS +# if set to "" will use all available adapters +# for select adapters use comma seperated list of adapter +# numbers, i.e. to use /dev/dvb/adapter0 and /dev/dvb/adapter1 only +# set as "0,1" +TVH_ADAPTERS="" + +# TVH_IPV6 +# if set to 1 will enable IPv6 support +TVH_IPV6=0 + +# TVH_HTTP_PORT +# if set to "" will use binary default +TVH_HTTP_PORT="" + +# TVH_HTTP_ROOT +# if set to "" will use binary default +# else will change the webui root context, useful for proxied +# servers +TVH_HTTP_ROOT="" + +# TVH_HTSP_PORT +# if set to "" will use binary default +TVH_HTSP_PORT="" + +# TVH_DEBUG +# if set to 1 will output debug to syslog +TVH_DEBUG=0 + +# TVH_ARGS +# add any other arguments +TVH_ARGS="" + diff --git a/doc/screenshots/overall_screenshot.png b/doc/screenshots/overall_screenshot.png new file mode 100644 index 0000000..dbe9cf9 Binary files /dev/null and b/doc/screenshots/overall_screenshot.png differ diff --git a/manifest.json b/manifest.json index ae85b55..371736a 100644 --- a/manifest.json +++ b/manifest.json @@ -6,15 +6,21 @@ "en": "TV streaming server and recorder", "fr": "Serveur de streaming et d'enregistrement TV" }, - "version": "4.3.1979~ynh5", + "version": "4.3.1979~ynh6", "url": "https://tvheadend.org", - "license": "free", + "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": ">= 3.5" + "yunohost": ">= 4.1" }, "multi_instance": false, "services": [ @@ -24,20 +30,11 @@ "install" : [ { "name": "domain", - "type": "domain", - "ask": { - "en": "Choose a domain name for Tvheadend", - "fr": "Choisissez un nom de domaine pour Tvheadend" - }, - "example": "example.com" + "type": "domain" }, { "name": "path", "type": "path", - "ask": { - "en": "Choose a path for Tvheadend", - "fr": "Choisissez un chemin pour Tvheadend" - }, "example": "/tvh", "default": "/tvh" }, @@ -52,16 +49,7 @@ }, { "name": "password", - "type": "password", - "ask": { - "en": "Set the superuser password", - "fr": "Définissez le mot de passe du superutilisateur" - }, - "help": { - "en": "Use the help field to add an information for the admin about this question.", - "fr": "Utilisez le champ aide pour ajouter une information à l'intention de l'administrateur à propos de cette question." - }, - "example": "Choose a password" + "type": "password" } ] } diff --git a/scripts/backup b/scripts/backup index bf2f5af..452fb5a 100644 --- a/scripts/backup +++ b/scripts/backup @@ -49,15 +49,6 @@ ynh_backup --src_path="$final_path" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# SPECIFIC BACKUP -#================================================= -# BACKUP LOGROTATE AND LOG FILE -#================================================= - -ynh_backup --src_path="/etc/logrotate.d/$app" -ynh_backup --src_path="/var/log/$app.log" - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/change_url b/scripts/change_url index 2fb1d43..d47d67b 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -24,17 +24,32 @@ app=$YNH_APP_INSTANCE_NAME #================================================= 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) +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 () { + # 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 @@ -54,7 +69,7 @@ fi #================================================= ynh_script_progression --message="Stopping Tvheadend service..." --weight=1 -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app.log" +ynh_systemd_action --service_name=$app --action="stop" #================================================= # MODIFY URL IN NGINX CONF @@ -63,19 +78,28 @@ ynh_script_progression --message="Updating NGINX web server configuration..." -- nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf -# Change the path in the nginx config file +# 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 + # 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 + # Set global variables for NGINX helper domain="$old_domain" path_url="$new_path" - # Create a dedicated nginx config + # 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 +# Change the domain for NGINX if [ $change_domain -eq 1 ] then # Delete file checksum for the old conf file location @@ -85,21 +109,6 @@ then ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi -#================================================= -# SPECIFIC MODIFICATIONS -#================================================= -# ... -#================================================= -ynh_script_progression --message="Updating Tvheadend configuration..." --weight=1 - -ynh_backup_if_checksum_is_different --file="/etc/default/tvheadend" -cp ../conf/tvheadend /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" #================================================= # GENERIC FINALISATION @@ -115,7 +124,7 @@ ynh_systemd_action --service_name=nginx --action=reload #================================================= ynh_script_progression --message="Starting $app service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app.log" +ynh_systemd_action --service_name=$app --action="start" #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index c7fd7c7..d40f91f 100644 --- a/scripts/install +++ b/scripts/install @@ -100,6 +100,11 @@ ynh_exec_quiet "wget -q -O $tvheadend_deb_dst $tvheadend_deb_url" #================================================= 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 + ynh_exec_warn_less DEBIAN_FRONTEND=noninteractive dpkg -i $tvheadend_deb_dst ynh_secure_remove --file="$temp_folder" @@ -118,12 +123,11 @@ 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 -ynh_add_config --template="tvheadend" --destination="/etc/default/tvheadend" - -# Copy and modify /home/hts/.hts/tvheadend/superuser -ynh_add_config --template="superuser" --destination="${conf_dir}/superuser" -chown hts:video "${conf_dir}/superuser" -chmod 600 "${conf_dir}/superuser" +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" #================================================= # NGINX CONFIGURATION @@ -133,28 +137,18 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=2 # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Configuring log rotation..." --weight=1 - -# Use logrotate to manage application logfile(s) -touch /var/log/$app.log -chmod 666 /var/log/$app.log -ynh_use_logrotate --logfile=/var/log/$app.log - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= 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" +yunohost service add $app --description="TV streaming server and recorder" --needs_exposed_ports $port $stream_port #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." --weight=1 +ynh_script_progression --message="Configuring permissions..." --weight=1 -ynh_app_setting_set --app=$app --key=skipped_uris --value="/" +ynh_permission_update --permission="main" --add="visitors" #================================================= # RELOAD NGINX @@ -175,7 +169,7 @@ apt-mark hold tvheadend #================================================= ynh_script_progression --message="Starting Tvheadend service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app.log" +ynh_systemd_action --service_name=$app --action="start" #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index 289b48e..a319101 100644 --- a/scripts/remove +++ b/scripts/remove @@ -58,18 +58,6 @@ then yunohost service remove $app fi -#================================================= -# REMOVE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Removing logrotate configuration..." --weight=1 - -# Remove the app-specific logrotate config -ynh_remove_logrotate - -ynh_script_progression --message="Removing $app log file..." --weight=1 - -# Remove the log files -ynh_secure_remove --file="/var/log/$app.log" #================================================= # REMOVE DEPENDENCIES diff --git a/scripts/restore b/scripts/restore index 0345710..93c22ce 100644 --- a/scripts/restore +++ b/scripts/restore @@ -35,8 +35,6 @@ stream_port=$(ynh_app_setting_get --app=$app --key=stream_port) #================================================= 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}" test ! -d $final_path \ || ynh_die --message="There is already a directory: $final_path " @@ -93,6 +91,11 @@ ynh_exec_quiet "wget -q -O $tvheadend_deb_dst $tvheadend_deb_url" #================================================= 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 + ynh_exec_warn_less DEBIAN_FRONTEND=noninteractive dpkg -i $tvheadend_deb_dst ynh_secure_remove --file="$temp_folder" @@ -118,26 +121,20 @@ ynh_script_progression --message="Restoring NGINX web server configuration..." - ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# 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" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= 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" +yunohost service add $app --description="TV streaming server and recorder" --needs_exposed_ports $port $stream_port + #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." --weight=1 +ynh_script_progression --message="Configuring permissions..." --weight=1 -ynh_app_setting_set --app=$app --key=skipped_uris --value="/" +ynh_permission_update --permission="main" --add="visitors" #================================================= # RELOAD NGINX @@ -158,7 +155,7 @@ apt-mark hold tvheadend #================================================= ynh_script_progression --message="Starting Tvheadend service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app.log" +ynh_systemd_action --service_name=$app --action="start" #================================================= # END OF SCRIPT diff --git a/scripts/upgrade b/scripts/upgrade index c4ff0ad..f3db238 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -50,7 +50,7 @@ ynh_abort_if_errors #================================================= 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" #================================================= @@ -108,13 +108,12 @@ then 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 - ynh_add_config --template="superuser" --destination="${conf_dir}/superuser" - chown hts:video "${conf_dir}/superuser" - chmod 600 "${conf_dir}/superuser" - + 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 @@ -128,11 +127,25 @@ ynh_add_nginx_config #================================================= -# SETUP SSOWAT +# ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Configuring SSOwat..." --weight=1 +ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 +if ynh_legacy_permissions_exists; then + ynh_legacy_permissions_delete_all -ynh_app_setting_set --app=$app --key=skipped_uris --value="/" + ynh_app_setting_delete --app=$app --key=is_public +fi + +if ! ynh_permission_exists --permission="main"; then + # Create the required permissions + ynh_permission_create --permission="main" --allowed="visitors" +fi + +#================================================= +# 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 $port $stream_port #================================================= # RELOAD NGINX @@ -151,7 +164,7 @@ apt-mark hold tvheadend #================================================= ynh_script_progression --message="Starting Tvheadend service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app.log" +ynh_systemd_action --service_name=$app --action="start" #================================================= # END OF SCRIPT