
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 24s
59 lines
2.1 KiB
Bash
Executable File
59 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
# Test camera RTSP connection
|
|
# shellcheck disable=SC1091
|
|
|
|
# Handle both dropshell execution and manual execution
|
|
if [ -z "${AGENT_PATH}" ]; then
|
|
# Manual execution - set paths relative to template directory
|
|
AGENT_PATH="../../../agent/"
|
|
# Load from the actual deployed config, not template config
|
|
source "../config/.template_info.env"
|
|
source "../config/service.env"
|
|
fi
|
|
|
|
source "${AGENT_PATH}/common.sh"
|
|
_check_required_env_vars "CAMERA_IP" "CAMERA_USER" "CAMERA_PASSWORD" "CAMERA_RTSP_PORT"
|
|
|
|
echo "Testing camera connection..."
|
|
echo "Camera IP: ${CAMERA_IP}"
|
|
echo "Camera User: ${CAMERA_USER}"
|
|
echo "RTSP Port: ${CAMERA_RTSP_PORT}"
|
|
|
|
# URL-encode the password if it contains special characters
|
|
ENCODED_PASSWORD=$(echo -n "${CAMERA_PASSWORD}" | sed 's/!/%21/g; s/@/%40/g; s/#/%23/g; s/\$/%24/g; s/&/%26/g')
|
|
|
|
RTSP_URL="rtsp://${CAMERA_USER}:${ENCODED_PASSWORD}@${CAMERA_IP}:${CAMERA_RTSP_PORT}/cam/realmonitor?channel=1&subtype=0"
|
|
|
|
echo ""
|
|
echo "Testing RTSP URL (password hidden): rtsp://${CAMERA_USER}:****@${CAMERA_IP}:${CAMERA_RTSP_PORT}/cam/realmonitor?channel=1&subtype=0"
|
|
|
|
# Test with ffprobe
|
|
echo ""
|
|
echo "Testing with ffprobe..."
|
|
docker run --rm --network host \
|
|
--entrypoint ffprobe \
|
|
linuxserver/ffmpeg:latest \
|
|
-v error \
|
|
"${RTSP_URL}" 2>&1 | head -20
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo "✓ Camera connection successful!"
|
|
else
|
|
echo "✗ Camera connection failed"
|
|
echo ""
|
|
echo "Trying alternative RTSP paths..."
|
|
|
|
# Try without subtype parameter
|
|
ALT_URL="rtsp://${CAMERA_USER}:${ENCODED_PASSWORD}@${CAMERA_IP}:${CAMERA_RTSP_PORT}/cam/realmonitor?channel=1"
|
|
docker run --rm --network host --entrypoint ffprobe linuxserver/ffmpeg:latest \
|
|
-v error "${ALT_URL}" 2>&1 | head -5
|
|
|
|
# Try simple path
|
|
SIMPLE_URL="rtsp://${CAMERA_USER}:${ENCODED_PASSWORD}@${CAMERA_IP}:${CAMERA_RTSP_PORT}/"
|
|
docker run --rm --network host --entrypoint ffprobe linuxserver/ffmpeg:latest \
|
|
-v error "${SIMPLE_URL}" 2>&1 | head -5
|
|
fi
|
|
|
|
echo ""
|
|
echo "Checking MediaMTX container logs..."
|
|
docker logs "${PROJECT_NAME}-mediamtx" --tail 20 2>&1 | grep -E "(ERR|WARN|connected|disconnected|error)" |