From e2e6ad593550c5051e9bb71aac262a5db414ad93 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Mon, 24 Mar 2025 11:04:30 +0100 Subject: [PATCH] Refactor: ErsatzTV Script (#3365) * Update ersatztv-install.sh * Redesign ErsatzTV * Update ersatztv-install.sh * Update ersatztv.sh --- ct/ersatztv.sh | 21 +++++++++++++----- install/ersatztv-install.sh | 43 +++++++++++++++++++------------------ 2 files changed, 38 insertions(+), 26 deletions(-) diff --git a/ct/ersatztv.sh b/ct/ersatztv.sh index aa0b0ae58..0ca5d5c41 100644 --- a/ct/ersatztv.sh +++ b/ct/ersatztv.sh @@ -26,29 +26,40 @@ function update_script() { msg_error "No ${APP} Installation Found!" exit fi - + RELEASE=$(curl -s https://api.github.com/repos/ErsatzTV/ErsatzTV/releases | grep -oP '"tag_name": "\K[^"]+' | head -n 1) + if [[ ! -f /opt/${APP}_version.txt && $(echo "x.x.x" > /opt/${APP}_version.txt) || "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then msg_info "Stopping ErsatzTV" systemctl stop ersatzTV msg_ok "Stopped ErsatzTV" msg_info "Updating ErsatzTV" - RELEASE=$(curl -s https://api.github.com/repos/ErsatzTV/ErsatzTV/releases | grep -oP '"tag_name": "\K[^"]+' | head -n 1) cp -R /opt/ErsatzTV/ ErsatzTV-backup rm ErsatzTV-backup/ErsatzTV rm -rf /opt/ErsatzTV - wget -qO- "https://github.com/ErsatzTV/ErsatzTV/releases/download/${RELEASE}/ErsatzTV-${RELEASE}-linux-x64.tar.gz" | tar -xz -C /opt - mv "/opt/ErsatzTV-${RELEASE}-linux-x64" /opt/ErsatzTV + temp_file=$(mktemp) + wget -qO- https://github.com/ErsatzTV/ErsatzTV/releases/download/${RELEASE}/ErsatzTV-${RELEASE}-linux-x64.tar.gz -O "$temp_file" + tar -xzf "$temp_file" + mv /opt/ErsatzTV-${RELEASE}-linux-x64 /opt/ErsatzTV cp -R ErsatzTV-backup/* /opt/ErsatzTV/ rm -rf ErsatzTV-backup + echo "${RELEASE}" >/opt/${APP}_version.txt msg_ok "Updated ErsatzTV" msg_info "Starting ErsatzTV" systemctl start ersatzTV msg_ok "Started ErsatzTV" + + msg_info "Cleaning Up" + rm -f ${temp_file} + msg_ok "Cleaned" msg_ok "Updated Successfully" - exit + else + msg_ok "No update required. ${APP} is already at ${RELEASE}" + fi + exit } + start build_container description diff --git a/install/ersatztv-install.sh b/install/ersatztv-install.sh index 436136db5..a4fad8beb 100644 --- a/install/ersatztv-install.sh +++ b/install/ersatztv-install.sh @@ -1,12 +1,11 @@ #!/usr/bin/env bash # Copyright (c) 2021-2025 tteck -# Author: tteck -# Co-Author: MickLesk (Canbiz) +# Author: MickLesk (Canbiz) # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE -# Source: https://github.com/ErsatzTV/ErsatzTV +# Source: https://ersatztv.org/ -source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" color verb_ip6 catch_errors @@ -15,22 +14,20 @@ network_check update_os msg_info "Installing Dependencies" -$STD apt-get install -y curl -$STD apt-get install -y sudo -$STD apt-get install -y mc +$STD apt-get install -y \ + curl \ + sudo \ + mc msg_ok "Installed Dependencies" msg_info "Installing FFmpeg (Patience)" -wget -q https://www.deb-multimedia.org/pool/main/d/deb-multimedia-keyring/deb-multimedia-keyring_2016.8.1_all.deb -$STD dpkg -i deb-multimedia-keyring_2016.8.1_all.deb -cat </etc/apt/sources.list.d/backports.list -deb https://www.deb-multimedia.org bookworm main non-free -deb https://www.deb-multimedia.org bookworm-backports main -EOF -$STD apt update -DEBIAN_FRONTEND=noninteractive $STD apt-get install -t bookworm-backports ffmpeg -y -rm -rf /etc/apt/sources.list.d/backports.list deb-multimedia-keyring_2016.8.1_all.deb -$STD apt update +cd /usr/local/bin +wget -q https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz +$STD tar -xvf ffmpeg-release-amd64-static.tar.xz +rm -f ffmpeg-*.tar.xz +cd ffmpeg-* +mv ffmpeg ffprobe /usr/local/bin/ +rm -rf /usr/local/bin/ffmpeg-* msg_ok "Installed FFmpeg" msg_info "Setting Up Hardware Acceleration" @@ -44,10 +41,13 @@ if [[ "$CTTYPE" == "0" ]]; then fi msg_ok "Set Up Hardware Acceleration" -msg_info "Installing ErsatzTV" +msg_info "Installing ErsatzTV" +cd /opt RELEASE=$(curl -s https://api.github.com/repos/ErsatzTV/ErsatzTV/releases | grep -oP '"tag_name": "\K[^"]+' | head -n 1) -wget -qO- "https://github.com/ErsatzTV/ErsatzTV/releases/download/${RELEASE}/ErsatzTV-${RELEASE}-linux-x64.tar.gz" | tar -xz -C /opt -mv "/opt/ErsatzTV-${RELEASE}-linux-x64" /opt/ErsatzTV +wget -qO- "https://github.com/ErsatzTV/ErsatzTV/releases/download/${RELEASE}/ErsatzTV-${RELEASE}-linux-x64.tar.gz" -O "$temp_file" +tar -xzf "$temp_file" +mv /opt/ErsatzTV-${RELEASE}-linux-x64 /opt/ErsatzTV +echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt" msg_ok "Installed ErsatzTV" msg_info "Creating Service" @@ -67,13 +67,14 @@ RestartSec=30 [Install] WantedBy=multi-user.target EOF -systemctl -q --now enable ersatzTV.service +systemctl enable -q --now ersatzTV msg_ok "Created Service" motd_ssh customize msg_info "Cleaning up" +rm -f ${temp_file} $STD apt-get -y autoremove $STD apt-get -y autoclean msg_ok "Cleaned"