From 3b914ec2770ee44d280b6c4b2814d0817cf99965 Mon Sep 17 00:00:00 2001 From: bilulib Date: Tue, 13 May 2025 00:43:09 +0200 Subject: [PATCH 1/5] New Script: Huntarr --- ct/huntarr.sh | 106 ++++++++++++++++++++++++++++++ frontend/public/json/huntarr.json | 34 ++++++++++ install/huntarr-install.sh | 70 ++++++++++++++++++++ 3 files changed, 210 insertions(+) create mode 100644 ct/huntarr.sh create mode 100644 frontend/public/json/huntarr.json create mode 100644 install/huntarr-install.sh diff --git a/ct/huntarr.sh b/ct/huntarr.sh new file mode 100644 index 00000000..9585d0b0 --- /dev/null +++ b/ct/huntarr.sh @@ -0,0 +1,106 @@ +#!/usr/bin/env bash +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +# Copyright (c) 2021-2025 community-scripts ORG +# Author: BiluliB +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/plexguide/Huntarr.io + +APP="Huntarr" +var_tags="${var_tags:-arr}" +var_cpu="${var_cpu:-2}" +var_ram="${var_ram:-1024}" +var_disk="${var_disk:-4}" +var_os="${var_os:-debian}" +var_version="${var_version:-12}" +var_unprivileged="${var_unprivileged:-1}" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + + if [[ ! -f /opt/huntarr/main.py ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + RELEASE=$(curl -fsSL https://api.github.com/repos/plexguide/Huntarr.io/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}') + if [[ "${RELEASE}" != "$(cat /opt/huntarr_version.txt 2>/dev/null)" ]] || [[ ! -f /opt/huntarr_version.txt ]]; then + msg_info "Stopping $APP" + systemctl stop huntarr + msg_ok "Stopped $APP" + + msg_info "Checking system dependencies" + $STD apt-get update + $STD apt-get install -y \ + curl \ + tar \ + unzip \ + jq \ + python3 \ + python3-pip \ + python3-venv + msg_ok "System dependencies updated" + + msg_info "Creating Backup" + if ls /opt/${APP}_backup_*.tar.gz &>/dev/null; then + rm -f /opt/${APP}_backup_*.tar.gz + msg_info "Removed previous backup" + fi + tar -czf "/opt/${APP}_backup_$(date +%F).tar.gz" /opt/huntarr + msg_ok "Backup Created" + + msg_info "Updating $APP to v${RELEASE}" + curl -fsSL -o "/opt/huntarr/${RELEASE}.zip" "https://github.com/plexguide/Huntarr.io/archive/refs/tags/${RELEASE}.zip" + unzip -q -o "/opt/huntarr/${RELEASE}.zip" -d /tmp + cp -rf "/tmp/Huntarr.io-${RELEASE}"/* /opt/huntarr/ + + msg_info "Updating Python dependencies" + cd /opt/huntarr || exit + if [[ -f "/opt/huntarr/.requirements_checksum" ]]; then + CURRENT_CHECKSUM=$(md5sum requirements.txt | awk '{print $1}') + STORED_CHECKSUM=$(cat .requirements_checksum) + + if [[ "$CURRENT_CHECKSUM" != "$STORED_CHECKSUM" ]]; then + msg_info "Requirements have changed. Performing full upgrade." + /opt/huntarr/venv/bin/pip install --upgrade -r requirements.txt + else + msg_info "Requirements unchanged. Verifying installation." + /opt/huntarr/venv/bin/pip install -r requirements.txt + fi + else + /opt/huntarr/venv/bin/pip install --upgrade -r requirements.txt + fi + + md5sum requirements.txt | awk '{print $1}' >.requirements_checksum + msg_ok "Updated Python dependencies" + msg_ok "Updated $APP to v${RELEASE}" + + msg_info "Starting $APP" + systemctl start huntarr + msg_ok "Started $APP" + + msg_info "Cleaning Up" + rm -f "/opt/huntarr/${RELEASE}.zip" + rm -rf "/tmp/Huntarr.io-${RELEASE}" + msg_ok "Cleanup Completed" + + echo "${RELEASE}" >/opt/huntarr_version.txt + msg_ok "Update Successful" + fi + exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" +echo -e "${INFO}${YW} Access it using the following URL:${CL}" +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:9705${CL}" diff --git a/frontend/public/json/huntarr.json b/frontend/public/json/huntarr.json new file mode 100644 index 00000000..e9c83cb5 --- /dev/null +++ b/frontend/public/json/huntarr.json @@ -0,0 +1,34 @@ +{ + "name": "Huntarr", + "slug": "huntarr", + "categories": [ + 0 + ], + "date_created": "2025-05-12", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": 9705, + "documentation": "https://github.com/plexguide/Huntarr.io/wiki", + "website": "https://github.com/plexguide/Huntarr.io", + "logo": "https://raw.githubusercontent.com/plexguide/Huntarr.io/refs/heads/main/frontend/static/logo/Huntarr.svg", + "description": "Huntarr is a tool that automates the search for missing or low-quality media content in your collection. It works seamlessly with applications like Sonarr, Radarr, Lidarr, Readarr, and Whisparr, enhancing their functionality with continuous background scans to identify and update missed or outdated content. Through a user-friendly web interface accessible on port 9705, Huntarr provides real-time statistics, log views, and extensive configuration options. The software is especially useful for users who want to keep their media library up to date by automatically searching for missing episodes or higher-quality versions. Huntarr is well-suited for self-hosted environments and can easily run in LXC containers or Docker setups.", + "install_methods": [ + { + "type": "default", + "script": "ct/huntarr.sh", + "resources": { + "cpu": 2, + "ram": 1024, + "hdd": 4, + "os": "debian", + "version": "12" + } + } + ], + "default_credentials": { + "username": null, + "password": null + }, + "notes": [] +} diff --git a/install/huntarr-install.sh b/install/huntarr-install.sh new file mode 100644 index 00000000..683b4e2d --- /dev/null +++ b/install/huntarr-install.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 community-scripts ORG +# Author: BiluliB +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/plexguide/Huntarr.io + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +APPLICATION="huntarr" +REPO_NAME="Huntarr.io" + +msg_info "Installing Dependencies" +$STD apt-get install -y \ + curl \ + tar \ + unzip \ + jq \ + python3 \ + python3-pip \ + python3-venv +msg_ok "Installed System Dependencies" + +msg_info "Setup ${APPLICATION}" +RELEASE=$(curl -fsSL https://api.github.com/repos/plexguide/Huntarr.io/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') +curl -fsSL -o "${RELEASE}.zip" "https://github.com/plexguide/Huntarr.io/archive/refs/tags/${RELEASE}.zip" +unzip -q "${RELEASE}.zip" +mv "${REPO_NAME}-${RELEASE}/" "/opt/${APPLICATION}" + +echo "${RELEASE}" >/opt/${APPLICATION}_version.txt +msg_ok "Setup ${APPLICATION}" + +msg_info "Setting up Python Environment" +$STD python3 -m venv /opt/${APPLICATION}/venv +msg_ok "Created Python Virtual Environment" + +msg_info "Installing Python Dependencies" +$STD /opt/${APPLICATION}/venv/bin/pip install --upgrade pip +$STD /opt/${APPLICATION}/venv/bin/pip install -r /opt/${APPLICATION}/requirements.txt +msg_ok "Installed Python Dependencies" + +msg_info "Creating Service" +cat </etc/systemd/system/${APPLICATION}.service +[Unit] +Description=Huntarr Service +After=network.target +[Service] +WorkingDirectory=/opt/${APPLICATION} +ExecStart=/opt/${APPLICATION}/venv/bin/python /opt/${APPLICATION}/main.py +Restart=always +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now ${APPLICATION} +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +rm -f "${RELEASE}.zip" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" From aca0badf76d2c159728cb921db79176fba338d26 Mon Sep 17 00:00:00 2001 From: bilulib Date: Tue, 13 May 2025 00:57:00 +0200 Subject: [PATCH 2/5] New Script: Huntarr --- ct/headers/huntarr | 5 ++ ct/huntarr.sh | 106 ++++++++++++++++++++++++++++++ frontend/public/json/huntarr.json | 34 ++++++++++ install/huntarr-install.sh | 70 ++++++++++++++++++++ 4 files changed, 215 insertions(+) create mode 100644 ct/headers/huntarr create mode 100644 ct/huntarr.sh create mode 100644 frontend/public/json/huntarr.json create mode 100644 install/huntarr-install.sh diff --git a/ct/headers/huntarr b/ct/headers/huntarr new file mode 100644 index 00000000..d8521232 --- /dev/null +++ b/ct/headers/huntarr @@ -0,0 +1,5 @@ + __ __ __ + / / / /_ ______ / /_____ ___________ + / /_/ / / / / __ \/ __/ __ `/ ___/ ___/ + / __ / /_/ / / / / /_/ /_/ / / / / +/_/ /_/\__,_/_/ /_/\__/\__,_/_/ /_/ diff --git a/ct/huntarr.sh b/ct/huntarr.sh new file mode 100644 index 00000000..9585d0b0 --- /dev/null +++ b/ct/huntarr.sh @@ -0,0 +1,106 @@ +#!/usr/bin/env bash +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +# Copyright (c) 2021-2025 community-scripts ORG +# Author: BiluliB +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/plexguide/Huntarr.io + +APP="Huntarr" +var_tags="${var_tags:-arr}" +var_cpu="${var_cpu:-2}" +var_ram="${var_ram:-1024}" +var_disk="${var_disk:-4}" +var_os="${var_os:-debian}" +var_version="${var_version:-12}" +var_unprivileged="${var_unprivileged:-1}" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + + if [[ ! -f /opt/huntarr/main.py ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + RELEASE=$(curl -fsSL https://api.github.com/repos/plexguide/Huntarr.io/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}') + if [[ "${RELEASE}" != "$(cat /opt/huntarr_version.txt 2>/dev/null)" ]] || [[ ! -f /opt/huntarr_version.txt ]]; then + msg_info "Stopping $APP" + systemctl stop huntarr + msg_ok "Stopped $APP" + + msg_info "Checking system dependencies" + $STD apt-get update + $STD apt-get install -y \ + curl \ + tar \ + unzip \ + jq \ + python3 \ + python3-pip \ + python3-venv + msg_ok "System dependencies updated" + + msg_info "Creating Backup" + if ls /opt/${APP}_backup_*.tar.gz &>/dev/null; then + rm -f /opt/${APP}_backup_*.tar.gz + msg_info "Removed previous backup" + fi + tar -czf "/opt/${APP}_backup_$(date +%F).tar.gz" /opt/huntarr + msg_ok "Backup Created" + + msg_info "Updating $APP to v${RELEASE}" + curl -fsSL -o "/opt/huntarr/${RELEASE}.zip" "https://github.com/plexguide/Huntarr.io/archive/refs/tags/${RELEASE}.zip" + unzip -q -o "/opt/huntarr/${RELEASE}.zip" -d /tmp + cp -rf "/tmp/Huntarr.io-${RELEASE}"/* /opt/huntarr/ + + msg_info "Updating Python dependencies" + cd /opt/huntarr || exit + if [[ -f "/opt/huntarr/.requirements_checksum" ]]; then + CURRENT_CHECKSUM=$(md5sum requirements.txt | awk '{print $1}') + STORED_CHECKSUM=$(cat .requirements_checksum) + + if [[ "$CURRENT_CHECKSUM" != "$STORED_CHECKSUM" ]]; then + msg_info "Requirements have changed. Performing full upgrade." + /opt/huntarr/venv/bin/pip install --upgrade -r requirements.txt + else + msg_info "Requirements unchanged. Verifying installation." + /opt/huntarr/venv/bin/pip install -r requirements.txt + fi + else + /opt/huntarr/venv/bin/pip install --upgrade -r requirements.txt + fi + + md5sum requirements.txt | awk '{print $1}' >.requirements_checksum + msg_ok "Updated Python dependencies" + msg_ok "Updated $APP to v${RELEASE}" + + msg_info "Starting $APP" + systemctl start huntarr + msg_ok "Started $APP" + + msg_info "Cleaning Up" + rm -f "/opt/huntarr/${RELEASE}.zip" + rm -rf "/tmp/Huntarr.io-${RELEASE}" + msg_ok "Cleanup Completed" + + echo "${RELEASE}" >/opt/huntarr_version.txt + msg_ok "Update Successful" + fi + exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" +echo -e "${INFO}${YW} Access it using the following URL:${CL}" +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:9705${CL}" diff --git a/frontend/public/json/huntarr.json b/frontend/public/json/huntarr.json new file mode 100644 index 00000000..e9c83cb5 --- /dev/null +++ b/frontend/public/json/huntarr.json @@ -0,0 +1,34 @@ +{ + "name": "Huntarr", + "slug": "huntarr", + "categories": [ + 0 + ], + "date_created": "2025-05-12", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": 9705, + "documentation": "https://github.com/plexguide/Huntarr.io/wiki", + "website": "https://github.com/plexguide/Huntarr.io", + "logo": "https://raw.githubusercontent.com/plexguide/Huntarr.io/refs/heads/main/frontend/static/logo/Huntarr.svg", + "description": "Huntarr is a tool that automates the search for missing or low-quality media content in your collection. It works seamlessly with applications like Sonarr, Radarr, Lidarr, Readarr, and Whisparr, enhancing their functionality with continuous background scans to identify and update missed or outdated content. Through a user-friendly web interface accessible on port 9705, Huntarr provides real-time statistics, log views, and extensive configuration options. The software is especially useful for users who want to keep their media library up to date by automatically searching for missing episodes or higher-quality versions. Huntarr is well-suited for self-hosted environments and can easily run in LXC containers or Docker setups.", + "install_methods": [ + { + "type": "default", + "script": "ct/huntarr.sh", + "resources": { + "cpu": 2, + "ram": 1024, + "hdd": 4, + "os": "debian", + "version": "12" + } + } + ], + "default_credentials": { + "username": null, + "password": null + }, + "notes": [] +} diff --git a/install/huntarr-install.sh b/install/huntarr-install.sh new file mode 100644 index 00000000..683b4e2d --- /dev/null +++ b/install/huntarr-install.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 community-scripts ORG +# Author: BiluliB +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/plexguide/Huntarr.io + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +APPLICATION="huntarr" +REPO_NAME="Huntarr.io" + +msg_info "Installing Dependencies" +$STD apt-get install -y \ + curl \ + tar \ + unzip \ + jq \ + python3 \ + python3-pip \ + python3-venv +msg_ok "Installed System Dependencies" + +msg_info "Setup ${APPLICATION}" +RELEASE=$(curl -fsSL https://api.github.com/repos/plexguide/Huntarr.io/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') +curl -fsSL -o "${RELEASE}.zip" "https://github.com/plexguide/Huntarr.io/archive/refs/tags/${RELEASE}.zip" +unzip -q "${RELEASE}.zip" +mv "${REPO_NAME}-${RELEASE}/" "/opt/${APPLICATION}" + +echo "${RELEASE}" >/opt/${APPLICATION}_version.txt +msg_ok "Setup ${APPLICATION}" + +msg_info "Setting up Python Environment" +$STD python3 -m venv /opt/${APPLICATION}/venv +msg_ok "Created Python Virtual Environment" + +msg_info "Installing Python Dependencies" +$STD /opt/${APPLICATION}/venv/bin/pip install --upgrade pip +$STD /opt/${APPLICATION}/venv/bin/pip install -r /opt/${APPLICATION}/requirements.txt +msg_ok "Installed Python Dependencies" + +msg_info "Creating Service" +cat </etc/systemd/system/${APPLICATION}.service +[Unit] +Description=Huntarr Service +After=network.target +[Service] +WorkingDirectory=/opt/${APPLICATION} +ExecStart=/opt/${APPLICATION}/venv/bin/python /opt/${APPLICATION}/main.py +Restart=always +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now ${APPLICATION} +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +rm -f "${RELEASE}.zip" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" From 9b4e8f42364e564e86fe0ae8c20e38fea65d9d85 Mon Sep 17 00:00:00 2001 From: bilulib Date: Sat, 17 May 2025 03:37:01 +0200 Subject: [PATCH 3/5] Update huntarr.sh, huntarr-install.sh, huntarr.json --- ct/huntarr.sh | 30 +++++++++++--------------- frontend/public/json/huntarr.json | 2 +- install/huntarr-install.sh | 36 +++++++++++++------------------ 3 files changed, 28 insertions(+), 40 deletions(-) diff --git a/ct/huntarr.sh b/ct/huntarr.sh index 9585d0b0..fec79789 100644 --- a/ct/huntarr.sh +++ b/ct/huntarr.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func) # Copyright (c) 2021-2025 community-scripts ORG # Author: BiluliB # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE @@ -30,23 +30,11 @@ function update_script() { fi RELEASE=$(curl -fsSL https://api.github.com/repos/plexguide/Huntarr.io/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}') - if [[ "${RELEASE}" != "$(cat /opt/huntarr_version.txt 2>/dev/null)" ]] || [[ ! -f /opt/huntarr_version.txt ]]; then + if [[ "${RELEASE}" != "$(cat /opt/"${APP}"_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then msg_info "Stopping $APP" systemctl stop huntarr msg_ok "Stopped $APP" - msg_info "Checking system dependencies" - $STD apt-get update - $STD apt-get install -y \ - curl \ - tar \ - unzip \ - jq \ - python3 \ - python3-pip \ - python3-venv - msg_ok "System dependencies updated" - msg_info "Creating Backup" if ls /opt/${APP}_backup_*.tar.gz &>/dev/null; then rm -f /opt/${APP}_backup_*.tar.gz @@ -68,15 +56,19 @@ function update_script() { if [[ "$CURRENT_CHECKSUM" != "$STORED_CHECKSUM" ]]; then msg_info "Requirements have changed. Performing full upgrade." - /opt/huntarr/venv/bin/pip install --upgrade -r requirements.txt + uv pip install -r requirements.txt --python /opt/huntarr/venv/bin/python else msg_info "Requirements unchanged. Verifying installation." - /opt/huntarr/venv/bin/pip install -r requirements.txt + uv pip install -r requirements.txt --python /opt/huntarr/venv/bin/python fi else - /opt/huntarr/venv/bin/pip install --upgrade -r requirements.txt + if ! command -v uv &>/dev/null; then + msg_info "Installing UV package manager" + curl -LsSf https://astral.sh/uv/install.sh | sh + msg_ok "UV package manager installed" + fi + uv pip install -r requirements.txt --python /opt/huntarr/venv/bin/python fi - md5sum requirements.txt | awk '{print $1}' >.requirements_checksum msg_ok "Updated Python dependencies" msg_ok "Updated $APP to v${RELEASE}" @@ -92,6 +84,8 @@ function update_script() { echo "${RELEASE}" >/opt/huntarr_version.txt msg_ok "Update Successful" + else + msg_ok "No update required. ${APP} is already at v${RELEASE}" fi exit } diff --git a/frontend/public/json/huntarr.json b/frontend/public/json/huntarr.json index e9c83cb5..e37d5f1b 100644 --- a/frontend/public/json/huntarr.json +++ b/frontend/public/json/huntarr.json @@ -2,7 +2,7 @@ "name": "Huntarr", "slug": "huntarr", "categories": [ - 0 + 14 ], "date_created": "2025-05-12", "type": "ct", diff --git a/install/huntarr-install.sh b/install/huntarr-install.sh index 683b4e2d..732a3549 100644 --- a/install/huntarr-install.sh +++ b/install/huntarr-install.sh @@ -17,33 +17,27 @@ APPLICATION="huntarr" REPO_NAME="Huntarr.io" msg_info "Installing Dependencies" +$STD apt-get install -y jq +msg_ok "Installed Dependencies" + +msg_info "Installing Python" $STD apt-get install -y \ - curl \ - tar \ - unzip \ - jq \ python3 \ - python3-pip \ python3-venv -msg_ok "Installed System Dependencies" +$STD bash -c "curl -LsSf https://astral.sh/uv/install.sh | sh" +export PATH="/root/.local/bin:$HOME/.cargo/bin:$PATH" +command -v uv &>/dev/null +msg_ok "Installed Python" -msg_info "Setup ${APPLICATION}" +msg_info "Setting Up ${APPLICATION}" RELEASE=$(curl -fsSL https://api.github.com/repos/plexguide/Huntarr.io/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') -curl -fsSL -o "${RELEASE}.zip" "https://github.com/plexguide/Huntarr.io/archive/refs/tags/${RELEASE}.zip" -unzip -q "${RELEASE}.zip" -mv "${REPO_NAME}-${RELEASE}/" "/opt/${APPLICATION}" - +$STD curl -fsSL -o "${RELEASE}.zip" "https://github.com/plexguide/Huntarr.io/archive/refs/tags/${RELEASE}.zip" +$STD unzip -q "${RELEASE}.zip" +$STD mv "${REPO_NAME}-${RELEASE}/" "/opt/${APPLICATION}" echo "${RELEASE}" >/opt/${APPLICATION}_version.txt -msg_ok "Setup ${APPLICATION}" - -msg_info "Setting up Python Environment" -$STD python3 -m venv /opt/${APPLICATION}/venv -msg_ok "Created Python Virtual Environment" - -msg_info "Installing Python Dependencies" -$STD /opt/${APPLICATION}/venv/bin/pip install --upgrade pip -$STD /opt/${APPLICATION}/venv/bin/pip install -r /opt/${APPLICATION}/requirements.txt -msg_ok "Installed Python Dependencies" +$STD uv venv /opt/${APPLICATION}/venv +$STD uv pip install --python /opt/${APPLICATION}/venv/bin/python -r /opt/${APPLICATION}/requirements.txt +msg_ok "Setup ${APPLICATION} Complete" msg_info "Creating Service" cat </etc/systemd/system/${APPLICATION}.service From 0ee953df64b773048df67ed481181c4b0aaf7c4e Mon Sep 17 00:00:00 2001 From: bilulib Date: Sat, 17 May 2025 18:04:51 +0200 Subject: [PATCH 4/5] fix: standardize APP variable to lowercase "huntarr" for consistent paths --- ct/huntarr.sh | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/ct/huntarr.sh b/ct/huntarr.sh index fec79789..f7c055a0 100644 --- a/ct/huntarr.sh +++ b/ct/huntarr.sh @@ -5,7 +5,7 @@ source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxV # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE # Source: https://github.com/plexguide/Huntarr.io -APP="Huntarr" +APP="huntarr" var_tags="${var_tags:-arr}" var_cpu="${var_cpu:-2}" var_ram="${var_ram:-1024}" @@ -36,30 +36,30 @@ function update_script() { msg_ok "Stopped $APP" msg_info "Creating Backup" - if ls /opt/${APP}_backup_*.tar.gz &>/dev/null; then - rm -f /opt/${APP}_backup_*.tar.gz + if ls /opt/"${APP}"_backup_*.tar.gz &>/dev/null; then + rm -f /opt/"${APP}"_backup_*.tar.gz msg_info "Removed previous backup" fi - tar -czf "/opt/${APP}_backup_$(date +%F).tar.gz" /opt/huntarr + tar -czf "/opt/${APP}_backup_$(date +%F).tar.gz" /opt/"${APP}" msg_ok "Backup Created" msg_info "Updating $APP to v${RELEASE}" - curl -fsSL -o "/opt/huntarr/${RELEASE}.zip" "https://github.com/plexguide/Huntarr.io/archive/refs/tags/${RELEASE}.zip" - unzip -q -o "/opt/huntarr/${RELEASE}.zip" -d /tmp - cp -rf "/tmp/Huntarr.io-${RELEASE}"/* /opt/huntarr/ + curl -fsSL -o "/opt/${APP}/${RELEASE}.zip" "https://github.com/plexguide/Huntarr.io/archive/refs/tags/${RELEASE}.zip" + unzip -q -o "/opt/${APP}/${RELEASE}.zip" -d /tmp + cp -rf "/tmp/Huntarr.io-${RELEASE}"/* /opt/"${APP}"/ msg_info "Updating Python dependencies" - cd /opt/huntarr || exit - if [[ -f "/opt/huntarr/.requirements_checksum" ]]; then + cd /opt/"${APP}" || exit + if [[ -f "/opt/${APP}/.requirements_checksum" ]]; then CURRENT_CHECKSUM=$(md5sum requirements.txt | awk '{print $1}') STORED_CHECKSUM=$(cat .requirements_checksum) if [[ "$CURRENT_CHECKSUM" != "$STORED_CHECKSUM" ]]; then msg_info "Requirements have changed. Performing full upgrade." - uv pip install -r requirements.txt --python /opt/huntarr/venv/bin/python + uv pip install -r requirements.txt --python /opt/"${APP}"/venv/bin/python else msg_info "Requirements unchanged. Verifying installation." - uv pip install -r requirements.txt --python /opt/huntarr/venv/bin/python + uv pip install -r requirements.txt --python /opt/"${APP}"/venv/bin/python fi else if ! command -v uv &>/dev/null; then @@ -67,7 +67,7 @@ function update_script() { curl -LsSf https://astral.sh/uv/install.sh | sh msg_ok "UV package manager installed" fi - uv pip install -r requirements.txt --python /opt/huntarr/venv/bin/python + uv pip install -r requirements.txt --python /opt/"${APP}"/venv/bin/python fi md5sum requirements.txt | awk '{print $1}' >.requirements_checksum msg_ok "Updated Python dependencies" @@ -78,11 +78,11 @@ function update_script() { msg_ok "Started $APP" msg_info "Cleaning Up" - rm -f "/opt/huntarr/${RELEASE}.zip" + rm -f "/opt/${APP}/${RELEASE}.zip" rm -rf "/tmp/Huntarr.io-${RELEASE}" msg_ok "Cleanup Completed" - echo "${RELEASE}" >/opt/huntarr_version.txt + echo "${RELEASE}" >/opt/"${APP}"_version.txt msg_ok "Update Successful" else msg_ok "No update required. ${APP} is already at v${RELEASE}" From 9f3bc3d43c67fdd4ef03deb5a144b6d4ad46531b Mon Sep 17 00:00:00 2001 From: bilulib Date: Sat, 17 May 2025 23:56:35 +0200 Subject: [PATCH 5/5] refactor: replace direct UV installation with setup_uv function --- ct/huntarr.sh | 110 ++++++++++++++++++------------------- install/huntarr-install.sh | 18 +++--- 2 files changed, 62 insertions(+), 66 deletions(-) diff --git a/ct/huntarr.sh b/ct/huntarr.sh index f7c055a0..efc34566 100644 --- a/ct/huntarr.sh +++ b/ct/huntarr.sh @@ -24,69 +24,63 @@ function update_script() { check_container_storage check_container_resources - if [[ ! -f /opt/huntarr/main.py ]]; then + if [[ ! -f /opt/${APP}/main.py ]]; then msg_error "No ${APP} Installation Found!" exit fi - + setup_uv RELEASE=$(curl -fsSL https://api.github.com/repos/plexguide/Huntarr.io/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}') - if [[ "${RELEASE}" != "$(cat /opt/"${APP}"_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then - msg_info "Stopping $APP" - systemctl stop huntarr - msg_ok "Stopped $APP" - - msg_info "Creating Backup" - if ls /opt/"${APP}"_backup_*.tar.gz &>/dev/null; then - rm -f /opt/"${APP}"_backup_*.tar.gz - msg_info "Removed previous backup" - fi - tar -czf "/opt/${APP}_backup_$(date +%F).tar.gz" /opt/"${APP}" - msg_ok "Backup Created" - - msg_info "Updating $APP to v${RELEASE}" - curl -fsSL -o "/opt/${APP}/${RELEASE}.zip" "https://github.com/plexguide/Huntarr.io/archive/refs/tags/${RELEASE}.zip" - unzip -q -o "/opt/${APP}/${RELEASE}.zip" -d /tmp - cp -rf "/tmp/Huntarr.io-${RELEASE}"/* /opt/"${APP}"/ - - msg_info "Updating Python dependencies" - cd /opt/"${APP}" || exit - if [[ -f "/opt/${APP}/.requirements_checksum" ]]; then - CURRENT_CHECKSUM=$(md5sum requirements.txt | awk '{print $1}') - STORED_CHECKSUM=$(cat .requirements_checksum) - - if [[ "$CURRENT_CHECKSUM" != "$STORED_CHECKSUM" ]]; then - msg_info "Requirements have changed. Performing full upgrade." - uv pip install -r requirements.txt --python /opt/"${APP}"/venv/bin/python - else - msg_info "Requirements unchanged. Verifying installation." - uv pip install -r requirements.txt --python /opt/"${APP}"/venv/bin/python - fi - else - if ! command -v uv &>/dev/null; then - msg_info "Installing UV package manager" - curl -LsSf https://astral.sh/uv/install.sh | sh - msg_ok "UV package manager installed" - fi - uv pip install -r requirements.txt --python /opt/"${APP}"/venv/bin/python - fi - md5sum requirements.txt | awk '{print $1}' >.requirements_checksum - msg_ok "Updated Python dependencies" - msg_ok "Updated $APP to v${RELEASE}" - - msg_info "Starting $APP" - systemctl start huntarr - msg_ok "Started $APP" - - msg_info "Cleaning Up" - rm -f "/opt/${APP}/${RELEASE}.zip" - rm -rf "/tmp/Huntarr.io-${RELEASE}" - msg_ok "Cleanup Completed" - - echo "${RELEASE}" >/opt/"${APP}"_version.txt - msg_ok "Update Successful" - else - msg_ok "No update required. ${APP} is already at v${RELEASE}" + if [[ -f /opt/${APP}_version.txt ]] && [[ "${RELEASE}" == "$(cat /opt/${APP}_version.txt)" ]]; then + msg_ok "No update required. ${APP} is already at ${RELEASE}" + exit fi + msg_info "Stopping $APP" + systemctl stop ${APP} + msg_ok "Stopped $APP" + + msg_info "Creating Backup" + if ls /opt/"${APP}"_backup_*.tar.gz &>/dev/null; then + rm -f /opt/"${APP}"_backup_*.tar.gz + msg_info "Removed previous backup" + fi + tar -czf "/opt/${APP}_backup_$(date +%F).tar.gz" /opt/"${APP}" + msg_ok "Backup Created" + + msg_info "Updating $APP to v${RELEASE}" + temp_file=$(mktemp) + curl -fsSL -o "$temp_file" "https://github.com/plexguide/Huntarr.io/archive/refs/tags/${RELEASE}.zip" + unzip -q -o "$temp_file" -d /tmp + cp -rf "/tmp/Huntarr.io-${RELEASE}"/* /opt/"${APP}"/ + + msg_info "Updating Python dependencies" + cd /opt/"${APP}" || exit + if [[ -f "/opt/${APP}/.requirements_checksum" ]]; then + CURRENT_CHECKSUM=$(md5sum requirements.txt | awk '{print $1}') + STORED_CHECKSUM=$(cat .requirements_checksum) + if [[ "$CURRENT_CHECKSUM" != "$STORED_CHECKSUM" ]]; then + msg_info "Requirements have changed. Performing full upgrade." + $STD uv pip install -r requirements.txt --python /opt/"${APP}"/venv/bin/python + else + msg_info "Requirements unchanged. Verifying installation." + $STD uv pip install -r requirements.txt --python /opt/"${APP}"/venv/bin/python + fi + else + $STD uv pip install -r requirements.txt --python /opt/"${APP}"/venv/bin/python + fi + md5sum requirements.txt | awk '{print $1}' >.requirements_checksum + msg_ok "Updated Python dependencies" + + msg_info "Starting $APP" + systemctl start ${APP} + msg_ok "Started $APP" + + msg_info "Cleaning Up" + rm -f "$temp_file" + rm -rf "/tmp/Huntarr.io-${RELEASE}" + msg_ok "Cleanup Completed" + + echo "${RELEASE}" >/opt/"${APP}"_version.txt + msg_ok "Updated $APP to v${RELEASE}" exit } diff --git a/install/huntarr-install.sh b/install/huntarr-install.sh index 732a3549..5748642b 100644 --- a/install/huntarr-install.sh +++ b/install/huntarr-install.sh @@ -24,20 +24,22 @@ msg_info "Installing Python" $STD apt-get install -y \ python3 \ python3-venv -$STD bash -c "curl -LsSf https://astral.sh/uv/install.sh | sh" -export PATH="/root/.local/bin:$HOME/.cargo/bin:$PATH" -command -v uv &>/dev/null msg_ok "Installed Python" -msg_info "Setting Up ${APPLICATION}" +msg_info "Setup uv" +setup_uv +msg_ok "Setup uv" + +msg_info "Setting Up Huntarr" RELEASE=$(curl -fsSL https://api.github.com/repos/plexguide/Huntarr.io/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') -$STD curl -fsSL -o "${RELEASE}.zip" "https://github.com/plexguide/Huntarr.io/archive/refs/tags/${RELEASE}.zip" -$STD unzip -q "${RELEASE}.zip" +temp_file=$(mktemp) +$STD curl -fsSL -o "$temp_file" "https://github.com/plexguide/Huntarr.io/archive/refs/tags/${RELEASE}.zip" +$STD unzip -q "$temp_file" $STD mv "${REPO_NAME}-${RELEASE}/" "/opt/${APPLICATION}" echo "${RELEASE}" >/opt/${APPLICATION}_version.txt $STD uv venv /opt/${APPLICATION}/venv $STD uv pip install --python /opt/${APPLICATION}/venv/bin/python -r /opt/${APPLICATION}/requirements.txt -msg_ok "Setup ${APPLICATION} Complete" +msg_ok "Setup Huntrarr Complete" msg_info "Creating Service" cat </etc/systemd/system/${APPLICATION}.service @@ -58,7 +60,7 @@ motd_ssh customize msg_info "Cleaning up" -rm -f "${RELEASE}.zip" +rm -f "$temp_file" $STD apt-get -y autoremove $STD apt-get -y autoclean msg_ok "Cleaned"