d3ro-voice/scripts/nas-control.sh
Yun Chan 708e20f747
Some checks failed
CI Pipeline / Code Quality & Typecheck (push) Waiting to run
CI Pipeline / Test Suite (macos-latest) (push) Blocked by required conditions
CI Pipeline / Test Suite (ubuntu-latest) (push) Blocked by required conditions
CI Pipeline / Test Suite (windows-latest) (push) Blocked by required conditions
CI Pipeline / Build Validation (admin) (push) Blocked by required conditions
CI Pipeline / Build Validation (desktop) (push) Blocked by required conditions
Deploy Landing Page / deploy (push) Blocked by required conditions
Deploy Landing Page / build (push) Waiting to run
Release & Packaging Pipeline / Build & Publish Admin Docker Image (push) Failing after 8s
Release & Code Signing CA Pipeline / build-and-sign-windows (push) Failing after 1m51s
Build macOS / Build & Package (macOS) (push) Failing after 4s
Build macOS / Build & Package (macOS)-1 (push) Failing after 5s
Release & Code Signing CA Pipeline / build-and-sign-macos (push) Failing after 3s
Release & Packaging Pipeline / Package macOS Desktop App (push) Failing after 4s
Release & Packaging Pipeline / Package Windows Desktop App (push) Failing after 2m28s
Release & Packaging Pipeline / Publish Official GitHub Release (push) Has been skipped
feat: complete release preparation, 10+ ad mediation, CI/CD, and docker deployment
2026-08-20 11:12:05 +09:00

110 lines
3.5 KiB
Bash

#!/bin/bash
# ============================================================================
# scripts/nas-control.sh
# D3RO Voice — NAS Docker Container Management Utility
# ============================================================================
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
COMMAND="${1:-help}"
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
NC='\033[0m'
echo -e "${CYAN}====================================================${NC}"
echo -e "${CYAN} D3RO Voice — NAS Container Controller ${NC}"
echo -e "${CYAN}====================================================${NC}"
case "$COMMAND" in
start|up)
echo -e "${YELLOW}Starting D3RO Voice Cloud Service...${NC}"
mkdir -p data
docker compose up -d
echo -e "${GREEN}D3RO Voice is running!${NC}"
;;
stop|down)
echo -e "${YELLOW}Stopping D3RO Voice Cloud Service...${NC}"
docker compose down
echo -e "${GREEN}D3RO Voice stopped.${NC}"
;;
restart)
echo -e "${YELLOW}Restarting D3RO Voice Cloud Service...${NC}"
docker compose restart
echo -e "${GREEN}D3RO Voice restarted successfully.${NC}"
;;
status|ps)
echo -e "${YELLOW}Container Status:${NC}"
docker compose ps
echo ""
echo -e "${YELLOW}Health Check:${NC}"
PORT=$(grep -E '^PORT=' .env 2>/dev/null | cut -d '=' -f2 || echo "5000")
PORT=${PORT:-5000}
if command -v curl &> /dev/null; then
curl -s "http://localhost:$PORT/health" || echo -e "${RED}Failed to reach health endpoint on port $PORT${NC}"
echo ""
fi
;;
logs)
echo -e "${YELLOW}Showing live logs (Ctrl+C to exit)...${NC}"
docker compose logs -f d3ro-api-server
;;
backup)
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
BACKUP_FILE="d3ro_backup_${TIMESTAMP}.tar.gz"
echo -e "${YELLOW}Creating database and configuration backup (${BACKUP_FILE})...${NC}"
tar -czf "$BACKUP_FILE" data .env 2>/dev/null || tar -czf "$BACKUP_FILE" data
echo -e "${GREEN}Backup saved to: ${SCRIPT_DIR}/${BACKUP_FILE}${NC}"
;;
load)
IMAGE_TAR="${2:-d3ro-voice-api.tar}"
if [ -f "$IMAGE_TAR" ]; then
echo -e "${YELLOW}Loading Docker image from $IMAGE_TAR...${NC}"
docker load < "$IMAGE_TAR"
echo -e "${GREEN}Image loaded successfully.${NC}"
else
echo -e "${RED}Image archive $IMAGE_TAR not found!${NC}"
exit 1
fi
;;
update)
IMAGE_TAR="${2:-d3ro-voice-api.tar}"
if [ -f "$IMAGE_TAR" ]; then
echo -e "${YELLOW}Updating container from $IMAGE_TAR...${NC}"
docker load < "$IMAGE_TAR"
docker compose down
docker compose up -d
echo -e "${GREEN}D3RO Voice updated and restarted!${NC}"
else
echo -e "${RED}Image archive $IMAGE_TAR not found! Please place the new .tar file in this directory.${NC}"
exit 1
fi
;;
*)
echo "Usage: ./nas-control.sh [command]"
echo ""
echo "Available Commands:"
echo " start - Start the D3RO Voice service in the background"
echo " stop - Stop the D3RO Voice service"
echo " restart - Restart the container"
echo " status - Check container status and ping health check"
echo " logs - Follow container logs in real-time"
echo " backup - Create a compressed backup of the SQLite database and settings"
echo " load - Load docker image from d3ro-voice-api.tar"
echo " update - Load new d3ro-voice-api.tar and recreate the container"
echo ""
;;
esac