Files
KNEL-AIMiddleware/maintenance.sh
T
mrcharles b595e26d62 fix: add profile flags to all docker compose commands and complete env vars
All services in docker-compose.yml are behind profiles (dev/ops), but the
maintenance scripts called docker compose without --profile, so no services
were detected or built. Added --profile dev --profile ops to BuildAll.sh,
StatusCheck.sh, and all relevant maintenance.sh commands.

Also:
- Added missing env vars for 8 newer servers to .env.example (beszel, gitea,
  grafana, ha, limesurvey, linkwarden, superset)
- Fixed maintenance.sh validate to use validate-all.sh instead of nonexistent
  validate-mcp.sh
2026-07-30 12:15:49 -05:00

178 lines
4.0 KiB
Bash
Executable File

#!/bin/bash
# maintenance.sh
# Comprehensive maintenance script for KNEL-AIMiddleware
# Combines functionality from the old Makefile with Docker Compose
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Change to project directory
cd "$(dirname "${BASH_SOURCE[0]}")"
# Function to show usage
show_usage() {
cat << EOF
Usage: $0 <command>
Available commands:
clone-vendors Clone all vendor MCP/LSP repositories
build-all Build all MCP/LSP services
build <service> Build a specific service
clean-vendor Remove all cloned vendor repositories
status Check build status of all services
validate Validate MCP servers
logs Show logs from all running services
ps Show status of all services
up [profile] Start services (default: dev profile)
down Stop all services
rebuild <service> Rebuild a specific service
help Show this help message
Examples:
$0 clone-vendors
$0 build ghost-mcp
$0 rebuild context7-mcp
$0 up dev
$0 down
EOF
}
# Function to clone vendor repositories
clone_vendors() {
echo -e "${GREEN}=== Cloning Vendor Repositories ===${NC}"
./scripts/CloneVendorRepos.sh
}
# Function to build all services
build_all() {
echo -e "${GREEN}=== Building All Services ===${NC}"
./scripts/BuildAll.sh
}
# Function to build specific service
build_service() {
local service=$1
if [ -z "$service" ]; then
echo -e "${RED}Error: Service name required${NC}"
echo "Usage: $0 build <service-name>"
exit 1
fi
echo -e "${GREEN}=== Building $service ===${NC}"
docker compose --profile dev --profile ops build "$service"
}
# Function to clean vendor directory
clean_vendor() {
echo -e "${YELLOW}=== Cleaning Vendor Directory ===${NC}"
read -p "This will remove all cloned vendor repositories. Continue? (y/N) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
./scripts/CleanVendor.sh
else
echo "Cancelled."
fi
}
# Function to check status
status() {
echo -e "${GREEN}=== Service Status ===${NC}"
./scripts/StatusCheck.sh
}
# Function to validate MCP servers
validate() {
echo -e "${GREEN}=== Validating MCP Servers ===${NC}"
./scripts/validate-all.sh mcp
}
# Function to show logs
logs() {
echo -e "${GREEN}=== Service Logs ===${NC}"
docker compose --profile dev --profile ops logs -f
}
# Function to show process status
ps() {
echo -e "${GREEN}=== Service Process Status ===${NC}"
docker compose --profile dev --profile ops ps
}
# Function to start services
up() {
local profile=${1:-dev}
echo -e "${GREEN}=== Starting Services (profile: $profile) ===${NC}"
docker compose up -d --profile "$profile"
}
# Function to stop services
down() {
echo -e "${GREEN}=== Stopping Services ===${NC}"
docker compose down
}
# Function to rebuild service
rebuild() {
local service=$1
if [ -z "$service" ]; then
echo -e "${RED}Error: Service name required${NC}"
echo "Usage: $0 rebuild <service-name>"
exit 1
fi
echo -e "${GREEN}=== Rebuilding $service ===${NC}"
docker compose --profile dev --profile ops build --no-cache "$service"
docker compose --profile dev --profile ops up -d "$service"
}
# Main script logic
case "${1:-help}" in
clone-vendors)
clone_vendors
;;
build-all)
build_all
;;
build)
build_service "$2"
;;
clean-vendor)
clean_vendor
;;
status)
status
;;
validate)
validate
;;
logs)
logs
;;
ps)
ps
;;
up)
up "$2"
;;
down)
down
;;
rebuild)
rebuild "$2"
;;
help|--help|-h)
show_usage
;;
*)
echo -e "${RED}Unknown command: $1${NC}"
echo ""
show_usage
exit 1
;;
esac