114 lines
3.4 KiB
Bash
Executable File
114 lines
3.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Docker Compose command detection
|
|
if docker compose version &> /dev/null; then
|
|
COMPOSE="docker compose"
|
|
elif docker-compose --version &> /dev/null; then
|
|
COMPOSE="docker-compose"
|
|
else
|
|
echo "Error: Docker Compose not found!"
|
|
exit 1
|
|
fi
|
|
|
|
case "$1" in
|
|
start)
|
|
echo "Starting all services..."
|
|
$COMPOSE up -d
|
|
;;
|
|
stop)
|
|
echo "Stopping all services..."
|
|
$COMPOSE down
|
|
;;
|
|
restart)
|
|
echo "Restarting all services..."
|
|
$COMPOSE restart
|
|
;;
|
|
logs)
|
|
if [ -z "$2" ]; then
|
|
$COMPOSE logs -f
|
|
else
|
|
$COMPOSE logs -f "$2"
|
|
fi
|
|
;;
|
|
status)
|
|
$COMPOSE ps
|
|
;;
|
|
clean)
|
|
echo "Stopping and removing all containers and volumes..."
|
|
read -p "This will delete all data. Continue? (y/N) " -n 1 -r
|
|
echo
|
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
$COMPOSE down -v
|
|
echo "Cleanup complete!"
|
|
else
|
|
echo "Cancelled."
|
|
fi
|
|
;;
|
|
db)
|
|
echo "Opening scheduler database..."
|
|
if [ -f "scheduler.db" ]; then
|
|
sqlite3 scheduler.db
|
|
else
|
|
echo "Database file not found. Is the scheduler running?"
|
|
fi
|
|
;;
|
|
jobs)
|
|
echo "Current jobs:"
|
|
if [ -f "scheduler.db" ]; then
|
|
sqlite3 scheduler.db "SELECT nocodb_id, title, prep_status, play_status, datetime(run_at) as scheduled FROM jobs ORDER BY run_at;"
|
|
else
|
|
echo "Database file not found."
|
|
fi
|
|
;;
|
|
add-video)
|
|
if [ -z "$2" ]; then
|
|
echo "Usage: $0 add-video <path-to-video-file>"
|
|
exit 1
|
|
fi
|
|
if [ ! -f "$2" ]; then
|
|
echo "File not found: $2"
|
|
exit 1
|
|
fi
|
|
echo "Adding video to raw_movies volume..."
|
|
docker run --rm -v scheduler_raw_movies:/data -v "$(pwd):/host" alpine \
|
|
cp "/host/$2" /data/
|
|
echo "✓ Video added: $(basename "$2")"
|
|
echo "Now add an entry in NocoDB with Title matching: $(basename "$2" | cut -d. -f1)"
|
|
;;
|
|
stream)
|
|
echo "To watch the stream, use one of these commands:"
|
|
echo ""
|
|
echo "VLC:"
|
|
echo " vlc rtmp://localhost:1935/live/stream"
|
|
echo ""
|
|
echo "ffplay:"
|
|
echo " ffplay rtmp://localhost:1935/live/stream"
|
|
echo ""
|
|
echo "MPV:"
|
|
echo " mpv rtmp://localhost:1935/live/stream"
|
|
;;
|
|
*)
|
|
echo "Movie Scheduler - Docker Helper"
|
|
echo ""
|
|
echo "Usage: $0 <command> [arguments]"
|
|
echo ""
|
|
echo "Commands:"
|
|
echo " start Start all services"
|
|
echo " stop Stop all services"
|
|
echo " restart Restart all services"
|
|
echo " logs [service] View logs (all or specific service)"
|
|
echo " status Show service status"
|
|
echo " clean Stop and remove all data"
|
|
echo " db Open scheduler database (SQLite)"
|
|
echo " jobs List all jobs and their status"
|
|
echo " add-video <file> Add video to raw_movies volume"
|
|
echo " stream Show commands to watch the stream"
|
|
echo ""
|
|
echo "Examples:"
|
|
echo " $0 start"
|
|
echo " $0 logs scheduler"
|
|
echo " $0 add-video my-movie.mp4"
|
|
echo " $0 jobs"
|
|
;;
|
|
esac
|