From 76f95d6245675ff8b5c935e5a507a6b89e3d2234 Mon Sep 17 00:00:00 2001 From: Daniel Figus Date: Thu, 7 Nov 2024 14:16:30 +0000 Subject: [PATCH] Add WebGrab+Plus Remove support of armhf and i386 architecture as dotnet8 is not available there which is required for WG++ --- tvheadend/Dockerfile | 14 ++++ tvheadend/build.yaml | 2 - tvheadend/config.yaml | 7 +- tvheadend/rootfs/etc/crontabs/root | 1 + .../s6-rc.d/cron/dependencies.d/init-wg++ | 0 .../rootfs/etc/s6-overlay/s6-rc.d/cron/run | 10 +++ .../rootfs/etc/s6-overlay/s6-rc.d/cron/type | 1 + .../rootfs/etc/s6-overlay/s6-rc.d/cron/up | 1 + .../s6-rc.d/init-wg++/dependencies.d/base | 0 .../etc/s6-overlay/s6-rc.d/init-wg++/run | 69 +++++++++++++++++++ .../etc/s6-overlay/s6-rc.d/init-wg++/type | 1 + .../etc/s6-overlay/s6-rc.d/init-wg++/up | 1 + .../s6-overlay/s6-rc.d/user/contents.d/cron | 0 .../s6-rc.d/user/contents.d/init-wg++ | 0 tvheadend/rootfs/wg/tr.xsl | 22 ++++++ 15 files changed, 125 insertions(+), 4 deletions(-) create mode 100644 tvheadend/rootfs/etc/crontabs/root create mode 100644 tvheadend/rootfs/etc/s6-overlay/s6-rc.d/cron/dependencies.d/init-wg++ create mode 100755 tvheadend/rootfs/etc/s6-overlay/s6-rc.d/cron/run create mode 100755 tvheadend/rootfs/etc/s6-overlay/s6-rc.d/cron/type create mode 100755 tvheadend/rootfs/etc/s6-overlay/s6-rc.d/cron/up create mode 100644 tvheadend/rootfs/etc/s6-overlay/s6-rc.d/init-wg++/dependencies.d/base create mode 100755 tvheadend/rootfs/etc/s6-overlay/s6-rc.d/init-wg++/run create mode 100755 tvheadend/rootfs/etc/s6-overlay/s6-rc.d/init-wg++/type create mode 100755 tvheadend/rootfs/etc/s6-overlay/s6-rc.d/init-wg++/up create mode 100644 tvheadend/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/cron create mode 100644 tvheadend/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/init-wg++ create mode 100644 tvheadend/rootfs/wg/tr.xsl diff --git a/tvheadend/Dockerfile b/tvheadend/Dockerfile index dd33cba..3343938 100644 --- a/tvheadend/Dockerfile +++ b/tvheadend/Dockerfile @@ -209,6 +209,8 @@ RUN \ libxslt=1.1.39-r1 \ nginx=1.26.2-r0 \ linux-firmware-other=20240811-r0 \ + dotnet8-runtime=8.0.10-r0 \ + xmlstarlet=1.6.1-r2 \ && pip3 install \ --no-cache-dir \ --prefer-binary \ @@ -237,6 +239,18 @@ RUN \ && tar xfJ /picons/tmp/srp.tar.xz -C /picons/srp --strip-components=1 \ && rm -rf /picons/tmp +# install WebGrab+ +RUN \ + mkdir -p /wg/tmp \ +&& curl -o /wg/tmp/wg.tar.gz http://www.webgrabplus.com/sites/default/files/download/SW/V5.3.0/WebGrabPlus_V5.3_install.tar.gz \ +&& tar -zxvf /wg/tmp/wg.tar.gz -C /wg \ +&& /wg/.wg++/install.sh \ +&& sed -i "s|guide.xml|/config/tvheadend/wg++/guide.xml|g" /wg/.wg++/WebGrab++.config.xml \ +&& rm -rf /wg/tmp \ +&& curl -o /usr/bin/tv_grab_wg++ http://www.webgrabplus.com/sites/default/files/tv_grab_wg.txt \ +&& sed -i 's|~/.wg++/guide.xml|/config/tvheadend/wg++/guide.xml|g' /usr/bin/tv_grab_wg++ \ +&& chmod +x /usr/bin/tv_grab_wg++ + # Copy root filesystem COPY rootfs / diff --git a/tvheadend/build.yaml b/tvheadend/build.yaml index bd8399b..7964afa 100644 --- a/tvheadend/build.yaml +++ b/tvheadend/build.yaml @@ -2,6 +2,4 @@ build_from: aarch64: ghcr.io/hassio-addons/base/aarch64:16.3.4 amd64: ghcr.io/hassio-addons/base/amd64:16.3.4 - armhf: ghcr.io/hassio-addons/base/armhf:16.3.4 armv7: ghcr.io/hassio-addons/base/armv7:16.3.4 - i386: ghcr.io/hassio-addons/base/i386:16.3.4 diff --git a/tvheadend/config.yaml b/tvheadend/config.yaml index a3eca89..2bb34eb 100644 --- a/tvheadend/config.yaml +++ b/tvheadend/config.yaml @@ -12,9 +12,7 @@ panel_icon: mdi:television arch: - aarch64 - amd64 - - armhf - armv7 - - i386 host_network: true video: true usb: true @@ -72,6 +70,7 @@ options: init_commands: [] args: "" comskip_ini: "" + wg_channels: [] schema: system_packages: - str? @@ -79,3 +78,7 @@ schema: - str? args: str? comskip_ini: str? + wg_channels: + - country: str? + site: str? + channel: str? diff --git a/tvheadend/rootfs/etc/crontabs/root b/tvheadend/rootfs/etc/crontabs/root new file mode 100644 index 0000000..5c77d3a --- /dev/null +++ b/tvheadend/rootfs/etc/crontabs/root @@ -0,0 +1 @@ +0 0 * * * /wg/.wg++/run.net.sh diff --git a/tvheadend/rootfs/etc/s6-overlay/s6-rc.d/cron/dependencies.d/init-wg++ b/tvheadend/rootfs/etc/s6-overlay/s6-rc.d/cron/dependencies.d/init-wg++ new file mode 100644 index 0000000..e69de29 diff --git a/tvheadend/rootfs/etc/s6-overlay/s6-rc.d/cron/run b/tvheadend/rootfs/etc/s6-overlay/s6-rc.d/cron/run new file mode 100755 index 0000000..37160ff --- /dev/null +++ b/tvheadend/rootfs/etc/s6-overlay/s6-rc.d/cron/run @@ -0,0 +1,10 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash +# ============================================================================== +# Home Assistant Community Add-on: TVHeadend +# Start cron +# ============================================================================== + +bashio::log.info "Starting cron..." + +exec crond -f -l 2 diff --git a/tvheadend/rootfs/etc/s6-overlay/s6-rc.d/cron/type b/tvheadend/rootfs/etc/s6-overlay/s6-rc.d/cron/type new file mode 100755 index 0000000..5883cff --- /dev/null +++ b/tvheadend/rootfs/etc/s6-overlay/s6-rc.d/cron/type @@ -0,0 +1 @@ +longrun diff --git a/tvheadend/rootfs/etc/s6-overlay/s6-rc.d/cron/up b/tvheadend/rootfs/etc/s6-overlay/s6-rc.d/cron/up new file mode 100755 index 0000000..986e57f --- /dev/null +++ b/tvheadend/rootfs/etc/s6-overlay/s6-rc.d/cron/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/cron/run diff --git a/tvheadend/rootfs/etc/s6-overlay/s6-rc.d/init-wg++/dependencies.d/base b/tvheadend/rootfs/etc/s6-overlay/s6-rc.d/init-wg++/dependencies.d/base new file mode 100644 index 0000000..e69de29 diff --git a/tvheadend/rootfs/etc/s6-overlay/s6-rc.d/init-wg++/run b/tvheadend/rootfs/etc/s6-overlay/s6-rc.d/init-wg++/run new file mode 100755 index 0000000..3c4c8e9 --- /dev/null +++ b/tvheadend/rootfs/etc/s6-overlay/s6-rc.d/init-wg++/run @@ -0,0 +1,69 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash +# ============================================================================== +# Home Assistant Community Add-on: TVHeadend +# Updates WG++ channels in WG++ ini +# ============================================================================== +declare wg_channel +declare country +declare site +declare channel +declare filename + +bashio::log.info "Init WG++..." +# create WG++ guide folder in addon config folder +if ! bashio::fs.directory_exists "/config/tvheadend/wg++"; then + bashio::log.info "Creating WG++ folder in config folder..." + mkdir -p /config/tvheadend/wg++ +fi + +expectedParentDir="/wg/.wg++/siteini.pack" + +function verifySiteFile() { + local fullpath + + fullpath="$expectedParentDir"/"$1"/"$2".channels.xml + if ! bashio::fs.file_exists "$fullpath"; then + bashio::log.fatal + bashio::log.fatal "WG Channel Configuration is incorrect for country $1 site $2" + bashio::log.fatal "File $1/$2.channels.xml does not exist. Only use contries and sites" + bashio::log.fatal "(case-sensitive) from the WG++ siteini.pack folder" + bashio::exit.nok + fi + + rpath=$(realpath "$fullpath") + if [[ $rpath != ${expectedParentDir}* ]]; then + bashio::log.fatal + bashio::log.fatal "WG Channel Configuration is incorrect for country $1 site $2" + bashio::log.fatal "File $1/$2.channels.xml is traversing paths. Only use contries and sites" + bashio::log.fatal "(case-sensitive) from the WG++ siteini.pack folder" + bashio::exit.nok + bashio::exit.nok + fi + echo "$fullpath" +} + +# remove dummy channel from initial config xml +xmlstarlet ed -L -d "/settings/channel" /wg/.wg++/WebGrab++.config.xml + +# Add Channels into WG++ ini +if bashio::config.has_value 'wg_channels'; then + bashio::log.info "Updating WG++ Channels..." + for wg_channel in $(bashio::config 'wg_channels'); do + country=$(bashio::jq "$wg_channel" '.country') + site=$(bashio::jq "$wg_channel" '.site') + channel=$(bashio::jq "$wg_channel" '.channel') + bashio::log.info "Adding channel country: ${country} site: ${site} channel: ${channel} to wg++ config" + + filename=$(verifySiteFile "$country" "$site") + if [[ ! $(xmlstarlet sel -t -v "//channel[@site_id='$channel']" "$filename") ]]; then + bashio::log.fatal "Channel $channel does not exist in channel file of $site" + bashio::exit.nok + fi + + # run XSLT to copy over channel + xmlstarlet tr /wg/tr.xsl -s filename="$filename" -s channel="$channel" /wg/.wg++/WebGrab++.config.xml | xmlstarlet fo >/wg/.wg++/tmp.xml && + mv /wg/.wg++/tmp.xml /wg/.wg++/WebGrab++.config.xml + + done +fi diff --git a/tvheadend/rootfs/etc/s6-overlay/s6-rc.d/init-wg++/type b/tvheadend/rootfs/etc/s6-overlay/s6-rc.d/init-wg++/type new file mode 100755 index 0000000..3d92b15 --- /dev/null +++ b/tvheadend/rootfs/etc/s6-overlay/s6-rc.d/init-wg++/type @@ -0,0 +1 @@ +oneshot \ No newline at end of file diff --git a/tvheadend/rootfs/etc/s6-overlay/s6-rc.d/init-wg++/up b/tvheadend/rootfs/etc/s6-overlay/s6-rc.d/init-wg++/up new file mode 100755 index 0000000..8ffd1f5 --- /dev/null +++ b/tvheadend/rootfs/etc/s6-overlay/s6-rc.d/init-wg++/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/init-wg++/run diff --git a/tvheadend/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/cron b/tvheadend/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/cron new file mode 100644 index 0000000..e69de29 diff --git a/tvheadend/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/init-wg++ b/tvheadend/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/init-wg++ new file mode 100644 index 0000000..e69de29 diff --git a/tvheadend/rootfs/wg/tr.xsl b/tvheadend/rootfs/wg/tr.xsl new file mode 100644 index 0000000..7d4ad1e --- /dev/null +++ b/tvheadend/rootfs/wg/tr.xsl @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + +