try api validation

This commit is contained in:
12e70ig
2025-05-07 00:49:01 +02:00
parent 5fd159b812
commit a3f28b1c4f
3 changed files with 115 additions and 5 deletions

View File

@ -34,22 +34,48 @@ $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"
# Try to find package.json in subdirectories
PACKAGE_DIR=$(find /opt/huntarr -name package.json -type f -print -quit | xargs dirname)
# Use find with better subdirectory exploration - search deeper
PACKAGE_FILES=$(find /opt/huntarr -name package.json -type f -print -quit)
if [ -n "$PACKAGE_DIR" ]; then
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"
# Attempt to use a specific version that's known to work
msg_info "Trying alternate repository or specific version"
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/huntarr/huntarr/archive/refs/heads/master.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