refactor: replace Makefile with maintenance.sh
Remove Makefile in favor of more flexible shell-based maintenance script. The new maintenance.sh provides all the same functionality with easier maintenance and better shell script integration.
This commit is contained in:
177
maintenance.sh
Executable file
177
maintenance.sh
Executable file
@@ -0,0 +1,177 @@
|
||||
#!/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 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-mcp.sh
|
||||
}
|
||||
|
||||
# Function to show logs
|
||||
logs() {
|
||||
echo -e "${GREEN}=== Service Logs ===${NC}"
|
||||
docker compose logs -f
|
||||
}
|
||||
|
||||
# Function to show process status
|
||||
ps() {
|
||||
echo -e "${GREEN}=== Service Process Status ===${NC}"
|
||||
docker compose 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 build --no-cache "$service"
|
||||
docker compose 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
|
||||
Reference in New Issue
Block a user