diff --git a/ct/plex.sh b/ct/plex.sh index ce7be9d08..f19d4e51c 100644 --- a/ct/plex.sh +++ b/ct/plex.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) -# Copyright (c) 2021-2026 tteck -# Author: tteck (tteckster) +# Copyright (c) 2021-2026 community-scripts ORG +# Author: tteck (tteckster) | MickLesk (CanbiZ) # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE # Source: https://www.plex.tv/ @@ -24,28 +24,56 @@ function update_script() { header_info check_container_storage check_container_resources - if [[ ! -f /etc/apt/sources.list.d/plexmediaserver.list ]] && - [[ ! -f /etc/apt/sources.list.d/plexmediaserver.sources ]]; then + + if ! dpkg -l plexmediaserver &>/dev/null; then msg_error "No ${APP} Installation Found!" exit fi - UPD=$(msg_menu "Plex Update Options" \ - "1" "Update LXC" \ - "2" "Install plexupdate") - if [ "$UPD" == "1" ]; then - msg_info "Updating ${APP} LXC" - $STD apt update - $STD apt -y upgrade - msg_ok "Updated ${APP} LXC" - msg_ok "Updated successfully!" - exit + + # Migrate from old repository to new one if needed + if [[ -f /etc/apt/sources.list.d/plexmediaserver.sources ]]; then + local current_uri + current_uri=$(grep -oP '(?<=URIs: ).*' /etc/apt/sources.list.d/plexmediaserver.sources 2>/dev/null || true) + if [[ "$current_uri" == *"downloads.plex.tv/repo/deb"* ]]; then + msg_info "Migrating to new Plex repository" + rm -f /etc/apt/sources.list.d/plexmediaserver.sources + rm -f /usr/share/keyrings/PlexSign.asc + setup_deb822_repo \ + "plexmediaserver" \ + "https://downloads.plex.tv/plex-keys/PlexSign.v2.key" \ + "https://repo.plex.tv/deb/" \ + "public" \ + "main" + msg_ok "Migrated to new Plex repository" + fi + elif [[ -f /etc/apt/sources.list.d/plexmediaserver.list ]]; then + msg_info "Migrating to new Plex repository (deb822)" + rm -f /etc/apt/sources.list.d/plexmediaserver.list + rm -f /etc/apt/sources.list.d/plex* + rm -f /usr/share/keyrings/PlexSign.asc + setup_deb822_repo \ + "plexmediaserver" \ + "https://downloads.plex.tv/plex-keys/PlexSign.v2.key" \ + "https://repo.plex.tv/deb/" \ + "public" \ + "main" + msg_ok "Migrated to new Plex repository (deb822)" fi - if [ "$UPD" == "2" ]; then - set +e - bash -c "$(curl -fsSL https://raw.githubusercontent.com/mrworf/plexupdate/master/extras/installer.sh)" - msg_ok "Updated successfully!" - exit + + # Remove plexupdate if previously installed + if [[ -f /usr/local/bin/plexupdate ]] || [[ -d /opt/plexupdate ]]; then + msg_info "Removing legacy plexupdate" + rm -rf /opt/plexupdate /usr/local/bin/plexupdate + crontab -l 2>/dev/null | grep -v plexupdate | crontab - 2>/dev/null || true + msg_ok "Removed legacy plexupdate" fi + + msg_info "Updating ${APP}" + $STD apt update + $STD apt install -y plexmediaserver + msg_ok "Updated ${APP}" + + exit } start diff --git a/install/plex-install.sh b/install/plex-install.sh index bb29392c7..e2a142724 100644 --- a/install/plex-install.sh +++ b/install/plex-install.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash -# Copyright (c) 2021-2026 tteck -# Author: tteck (tteckster) +# Copyright (c) 2021-2026 community-scripts ORG +# Author: tteck (tteckster) | MickLesk (CanbiZ) # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE # Source: https://www.plex.tv/ @@ -16,19 +16,16 @@ update_os setup_hwaccel msg_info "Setting Up Plex Media Server Repository" -curl -fsSL https://downloads.plex.tv/plex-keys/PlexSign.key | tee /usr/share/keyrings/PlexSign.asc >/dev/null -cat </etc/apt/sources.list.d/plexmediaserver.sources -Types: deb -URIs: https://downloads.plex.tv/repo/deb/ -Suites: public -Components: main -Signed-By: /usr/share/keyrings/PlexSign.asc -EOF +setup_deb822_repo \ + "plexmediaserver" \ + "https://downloads.plex.tv/plex-keys/PlexSign.v2.key" \ + "https://repo.plex.tv/deb/" \ + "public" \ + "main" msg_ok "Set Up Plex Media Server Repository" msg_info "Installing Plex Media Server" -$STD apt update -$STD apt -o Dpkg::Options::="--force-confold" install -y plexmediaserver +$STD apt install -y plexmediaserver if [[ "$CTTYPE" == "0" ]]; then sed -i -e 's/^ssl-cert:x:104:plex$/render:x:104:root,plex/' -e 's/^render:x:108:root$/ssl-cert:x:108:plex/' /etc/group else