install-service.sh•1.91 kB
#!/bin/bash
################################################################################
# Install Systemd Service for KYC MCP Server
# This script installs and enables the systemd service
################################################################################
set -euo pipefail
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Logging functions
log_info() {
echo -e "${GREEN}[INFO]${NC} $1"
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Check if running as root
if [ "$EUID" -ne 0 ]; then
log_error "Please run as root or with sudo"
exit 1
fi
SERVICE_NAME="kyc-mcp.service"
SERVICE_FILE="/etc/systemd/system/$SERVICE_NAME"
SOURCE_FILE="$(dirname "$0")/$SERVICE_NAME"
log_info "Installing KYC MCP Server systemd service..."
# Check if source file exists
if [ ! -f "$SOURCE_FILE" ]; then
log_error "Service file not found: $SOURCE_FILE"
exit 1
fi
# Copy service file
log_info "Copying service file to $SERVICE_FILE"
cp "$SOURCE_FILE" "$SERVICE_FILE"
chmod 644 "$SERVICE_FILE"
# Reload systemd
log_info "Reloading systemd daemon..."
systemctl daemon-reload
# Enable service
log_info "Enabling service to start on boot..."
systemctl enable "$SERVICE_NAME"
# Show service status
log_info "Service installed successfully!"
echo ""
echo "=========================================="
echo "Service Management Commands:"
echo "=========================================="
echo "Start service: sudo systemctl start $SERVICE_NAME"
echo "Stop service: sudo systemctl stop $SERVICE_NAME"
echo "Restart service: sudo systemctl restart $SERVICE_NAME"
echo "Check status: sudo systemctl status $SERVICE_NAME"
echo "View logs: sudo journalctl -u $SERVICE_NAME -f"
echo "=========================================="
echo ""
echo "To start the service now, run:"
echo " sudo systemctl start $SERVICE_NAME"