Skip to main content
Glama
user-data.sh2.51 kB
#!/bin/bash ################################################################################ # EC2 User Data Script for KYC MCP Server # This script runs on first boot to initialize the instance ################################################################################ set -euo pipefail # Variables from Terraform PROJECT_NAME="${project_name}" ENVIRONMENT="${environment}" # Log file LOG_FILE="/var/log/user-data.log" # Redirect output to log file exec > >(tee -a $LOG_FILE) exec 2>&1 echo "==========================================" echo "Starting EC2 initialization for $PROJECT_NAME" echo "Environment: $ENVIRONMENT" echo "Timestamp: $(date)" echo "==========================================" # Detect OS if [ -f /etc/os-release ]; then . /etc/os-release OS=$ID else echo "Cannot detect OS" exit 1 fi echo "Detected OS: $OS" # Update system echo "Updating system packages..." if [ "$OS" = "amzn" ]; then yum update -y elif [ "$OS" = "ubuntu" ]; then apt-get update DEBIAN_FRONTEND=noninteractive apt-get upgrade -y fi # Install CloudWatch agent echo "Installing CloudWatch agent..." if [ "$OS" = "amzn" ]; then yum install -y amazon-cloudwatch-agent elif [ "$OS" = "ubuntu" ]; then wget https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb dpkg -i -E ./amazon-cloudwatch-agent.deb rm amazon-cloudwatch-agent.deb fi # Create application directory echo "Creating application directory..." mkdir -p /opt/$PROJECT_NAME chmod 755 /opt/$PROJECT_NAME # Set hostname echo "Setting hostname..." hostnamectl set-hostname $PROJECT_NAME-$ENVIRONMENT # Configure timezone echo "Configuring timezone..." timedatectl set-timezone UTC # Enable automatic security updates if [ "$OS" = "ubuntu" ]; then echo "Enabling automatic security updates..." apt-get install -y unattended-upgrades dpkg-reconfigure -plow unattended-upgrades fi # Create swap file (2GB) echo "Creating swap file..." if [ ! -f /swapfile ]; then fallocate -l 2G /swapfile chmod 600 /swapfile mkswap /swapfile swapon /swapfile echo '/swapfile none swap sw 0 0' >> /etc/fstab sysctl vm.swappiness=10 echo 'vm.swappiness=10' >> /etc/sysctl.conf fi # Signal completion echo "==========================================" echo "EC2 initialization completed successfully" echo "Timestamp: $(date)" echo "==========================================" # Create completion marker touch /var/log/user-data-complete

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/CTD-Techs/CTD-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server