Files
dropshell-templates/squashkiwi-streaming/install.sh
Your Name 1733efbd28
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 41s
config: Update 2 files
2025-09-01 21:48:57 +12:00

54 lines
2.2 KiB
Bash
Executable File

#!/bin/bash
# shellcheck disable=SC1091
source "${AGENT_PATH}/common.sh"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/_paths.sh"
_check_required_env_vars "PROJECT_NAME" "LOCAL_DATA_FOLDER" "CAMERA_IP" "COURT_ID" "RECORDINGS_FOLDER"
# Create directories
# shellcheck disable=SC2046
create_items $(get_squashkiwi_streaming_paths) || _die "Failed to create directories"
mkdir -p "${RECORDINGS_FOLDER}/court_main"
mkdir -p "${RECORDINGS_FOLDER}/court_sub"
mkdir -p "${LOCAL_DATA_FOLDER}/config"
mkdir -p "${LOCAL_DATA_FOLDER}/config/overlay"
mkdir -p "${LOCAL_DATA_FOLDER}/config/web"
# Copy configuration files
cp -r "${SCRIPT_DIR}/config/"* "${LOCAL_DATA_FOLDER}/config/" || _die "Failed to copy config files"
# URL-encode the camera password if it contains special characters
if [[ "${CAMERA_PASSWORD}" == *[!\@\#\$\&\%]* ]]; then
echo "Note: Camera password contains special characters. Encoding for RTSP URL..."
CAMERA_PASSWORD_ENCODED=$(echo -n "${CAMERA_PASSWORD}" | sed 's/!/%21/g; s/@/%40/g; s/#/%23/g; s/\$/%24/g; s/&/%26/g; s/%/%25/g')
export CAMERA_PASSWORD="${CAMERA_PASSWORD_ENCODED}"
fi
# Test Docker
_check_docker_installed || _die "Docker test failed, aborting installation..."
# Test camera connection (optional check)
echo "Testing camera connection to ${CAMERA_IP}..."
if ping -c 1 -W 2 "${CAMERA_IP}" > /dev/null 2>&1; then
echo "✓ Camera IP is reachable"
else
echo "⚠ Warning: Camera IP ${CAMERA_IP} is not reachable. Please check camera connection."
fi
# Build overlay service
cd "${LOCAL_DATA_FOLDER}/config" || _die "Failed to change to config directory"
docker compose build overlay-service || _die "Failed to build overlay service"
# Stop any existing containers
bash "${SCRIPT_DIR}/stop.sh" 2>/dev/null || true
# Start services
bash "${SCRIPT_DIR}/start.sh" || _die "Failed to start services"
echo ""
echo "Installation of ${PROJECT_NAME} complete!"
echo "Access the stream at: http://$(hostname -I | awk '{print $1}'):${HOST_PORT}"
echo ""
echo "To enable optional features:"
echo " - Cloudflare tunnel: Set CLOUDFLARE_TUNNEL_TOKEN in service.env and run: docker compose --profile tunnel up -d"
echo " - Monitoring: docker compose --profile monitoring up -d"