Add MarkBase services startup/stop scripts
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled

Service Management Scripts:
- start_services.sh: Start Web, SSH, SMB servers
- stop_services.sh: Stop all servers gracefully

Features:
- Port conflict detection
- Graceful shutdown (SIGTERM + SIGKILL)
- Log file management
- Color-coded output

Ports:
- Web: 11438
- SSH: 2024
- SMB: 4445

Usage:
  ./scripts/start_services.sh
  ./scripts/stop_services.sh
This commit is contained in:
Warren
2026-06-24 11:36:22 +08:00
parent 7f7e88e2c4
commit ffc09b97bb
2 changed files with 223 additions and 0 deletions

96
scripts/stop_services.sh Executable file
View File

@@ -0,0 +1,96 @@
#!/bin/bash
# MarkBase Services Stop Script
# Stops all services: Web, SSH, SMB
set -e
PORT_WEB=11438
PORT_SSH=2024
PORT_SMB=4445
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
echo "================================================"
echo "MarkBase Services Stop"
echo "================================================"
echo ""
# Function to check if port is in use
check_port() {
local port=$1
if nc -z 127.0.0.1 $port 2>/dev/null; then
return 0 # Port is in use
else
return 1 # Port is free
fi
}
# Function to kill process on port
kill_port() {
local port=$1
local pid=$(lsof -t -i:$port 2>/dev/null)
if [ -n "$pid" ]; then
echo "${YELLOW}Killing process $pid on port $port${NC}"
kill $pid 2>/dev/null || true
sleep 1
# Force kill if still running
if check_port $port; then
echo "${YELLOW}Force killing process $pid${NC}"
kill -9 $pid 2>/dev/null || true
sleep 1
fi
fi
}
# Stop Web Server
echo "=== Stopping Web Server (Port $PORT_WEB) ==="
if check_port $PORT_WEB; then
kill_port $PORT_WEB
if check_port $PORT_WEB; then
echo "${RED}Web Server still running${NC}"
else
echo "${GREEN}Web Server stopped${NC}"
fi
else
echo "${YELLOW}Web Server not running${NC}"
fi
echo ""
# Stop SSH Server
echo "=== Stopping SSH Server (Port $PORT_SSH) ==="
if check_port $PORT_SSH; then
kill_port $PORT_SSH
if check_port $PORT_SSH; then
echo "${RED}SSH Server still running${NC}"
else
echo "${GREEN}SSH Server stopped${NC}"
fi
else
echo "${YELLOW}SSH Server not running${NC}"
fi
echo ""
# Stop SMB Server
echo "=== Stopping SMB Server (Port $PORT_SMB) ==="
if check_port $PORT_SMB; then
kill_port $PORT_SMB
if check_port $PORT_SMB; then
echo "${RED}SMB Server still running${NC}"
else
echo "${GREEN}SMB Server stopped${NC}"
fi
else
echo "${YELLOW}SMB Server not running${NC}"
fi
echo ""
# Summary
echo "================================================"
echo "MarkBase Services Stop Complete"
echo "================================================"
echo ""
echo "${GREEN}All services stopped${NC}"