#!/usr/bin/env bash # Copyright (c) 2021-2025 tteck # Author: tteck (tteckster) # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE # Source: https://github.com/huntarr/huntarr source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" color verb_ip6 catch_errors setting_up_container network_check update_os msg_info "Installing Dependencies" $STD apt-get install -y curl wget gnupg git openjdk-17-jdk nodejs npm msg_ok "Installed Dependencies" msg_info "Installing Huntarr" temp_file="$(mktemp)" mkdir -p /var/lib/huntarr/ chmod 775 /var/lib/huntarr/ # Korrekte API-URL für Huntarr.io (plexguide/Huntarr.io) RELEASE=$(curl -fsSL https://api.github.com/repos/plexguide/Huntarr.io/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') # Download der neuesten Version (angepasste URL) curl -fsSL "https://github.com/plexguide/Huntarr.io/archive/refs/tags/${RELEASE}.tar.gz" -o "$temp_file" $STD mkdir -p /opt/huntarr $STD tar -xzf "$temp_file" -C /opt/huntarr --strip-components=1 # Check if package.json exists if [ ! -f "/opt/huntarr/package.json" ]; then msg_info "Looking for package.json in subdirectories" # Use find with better subdirectory exploration - search deeper PACKAGE_FILES=$(find /opt/huntarr -name package.json -type f -print -quit) if [ -n "$PACKAGE_FILES" ]; then # Only use dirname when we actually found the file PACKAGE_DIR=$(dirname "$PACKAGE_FILES") msg_info "Found package.json in $PACKAGE_DIR" # Create symlinks or copy files to right locations cp -R "$PACKAGE_DIR"/* /opt/huntarr/ cd /opt/huntarr else # First approach failed, try the backup repository immediately msg_error "Could not find package.json in the extracted files" msg_info "Trying backup repository directly" # Clean up and try alternate repository rm -rf /opt/huntarr $STD mkdir -p /opt/huntarr # Try the known working repository $STD curl -fsSL "https://github.com/plexguide/Huntarr.io/archive/refs/tags/6.2.23.tar.gz" -o "$temp_file" $STD tar -xzf "$temp_file" -C /opt/huntarr --strip-components=1 # Verify if this worked by listing files ls -la /opt/huntarr # If still no package.json, try to look more deeply if [ ! -f "/opt/huntarr/package.json" ]; then msg_info "Exploring repository structure" # Find any package.json files in any subdirectory DEEP_PACKAGE=$(find /opt/huntarr -name package.json -type f | head -n 1) if [ -n "$DEEP_PACKAGE" ]; then DEEP_DIR=$(dirname "$DEEP_PACKAGE") msg_info "Found package.json in $DEEP_DIR" # Copy the directory containing package.json to root cp -R "$DEEP_DIR"/* /opt/huntarr/ else msg_error "Failed to find package.json anywhere in the repository" exit 1 fi fi cd /opt/huntarr fi else cd /opt/huntarr fi # Now install after finding the correct directory $STD npm install $STD npm run build chmod 775 /opt/huntarr msg_ok "Installed Huntarr" msg_info "Creating Service" cat </etc/systemd/system/huntarr.service [Unit] Description=Huntarr Service After=network.target [Service] UMask=0002 Type=simple WorkingDirectory=/opt/huntarr ExecStart=/usr/bin/npm start Restart=on-failure TimeoutStopSec=20 KillMode=process [Install] WantedBy=multi-user.target EOF systemctl enable -q --now huntarr msg_ok "Created Service" motd_ssh customize msg_info "Cleaning up" rm -rf "$temp_file" $STD apt-get -y autoremove $STD apt-get -y autoclean msg_ok "Cleaned"