refactor: move all remaining files to orig/ directory
Completed clean root directory structure: - Root now contains only: .git, .env, docs/, orig/ - Moved all remaining files and directories to orig/: - Config files (.claude, .dockerignore, .drone.yml, etc.) - All .env variants (except active .env) - Git config (.gitconfig, .github, .gitignore, etc.) - Tool configs (.golangci.yml, .revive.toml, etc.) - Documentation (*.md files, @prompts) - Build files (Dockerfiles, Makefile, go.mod, go.sum) - Docker compose files - All source directories (scripts, tests, tools, etc.) - Runtime directories (logs, monitoring, reports) - Dependency files (node_modules, lib, cache) - Special files (--delete) - Removed empty runtime directories (bin/, data/) V2 structure is now clean: - docs/planning/ - V2 planning documents - orig/ - Complete V1 codebase preserved - .env - Active environment config (not in git) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
149
orig/scripts/install-systemd-service.sh
Executable file
149
orig/scripts/install-systemd-service.sh
Executable file
@@ -0,0 +1,149 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Systemd Service Installation Script for MEV Bot
|
||||
# Installs and enables MEV Bot to auto-start on system boot
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
CYAN='\033[0;36m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
echo -e "${BLUE}🔧 MEV Bot Systemd Service Installation${NC}"
|
||||
echo -e "${BLUE}========================================${NC}"
|
||||
echo ""
|
||||
|
||||
# Check if running as root
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo -e "${RED}❌ Error: This script must be run as root or with sudo${NC}"
|
||||
echo -e "${YELLOW}Usage: sudo $0${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get the directory where the script is located
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
|
||||
echo -e "${BLUE}📁 Project root: ${PROJECT_ROOT}${NC}"
|
||||
|
||||
# Check if Docker is installed
|
||||
if ! command -v docker &> /dev/null; then
|
||||
echo -e "${RED}❌ Error: Docker is not installed${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if docker-compose.yml exists
|
||||
if [ ! -f "$PROJECT_ROOT/docker-compose.yml" ]; then
|
||||
echo -e "${RED}❌ Error: docker-compose.yml not found in $PROJECT_ROOT${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}✅ Docker and docker-compose.yml found${NC}"
|
||||
|
||||
# Create systemd service file with actual project path
|
||||
echo -e "${BLUE}📝 Creating systemd service file...${NC}"
|
||||
|
||||
SERVICE_FILE="/etc/systemd/system/mev-bot.service"
|
||||
|
||||
cat > "$SERVICE_FILE" << EOF
|
||||
[Unit]
|
||||
Description=MEV Bot Production Service
|
||||
Requires=docker.service
|
||||
After=docker.service network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
WorkingDirectory=$PROJECT_ROOT
|
||||
ExecStartPre=/usr/bin/docker compose pull --quiet
|
||||
ExecStart=/usr/bin/docker compose up -d
|
||||
ExecStop=/usr/bin/docker compose down
|
||||
ExecReload=/usr/bin/docker compose restart
|
||||
TimeoutStartSec=0
|
||||
Restart=on-failure
|
||||
RestartSec=10s
|
||||
|
||||
# Security settings
|
||||
User=root
|
||||
Group=docker
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
echo -e "${GREEN}✅ Service file created at $SERVICE_FILE${NC}"
|
||||
|
||||
# Reload systemd daemon
|
||||
echo -e "${BLUE}🔄 Reloading systemd daemon...${NC}"
|
||||
systemctl daemon-reload
|
||||
|
||||
# Enable the service
|
||||
echo -e "${BLUE}✅ Enabling MEV Bot service...${NC}"
|
||||
systemctl enable mev-bot.service
|
||||
|
||||
echo -e "${GREEN}✅ MEV Bot service enabled for auto-start on boot${NC}"
|
||||
|
||||
# Ask if user wants to start the service now
|
||||
echo ""
|
||||
read -p "Do you want to start the MEV Bot service now? (y/n) " -n 1 -r
|
||||
echo ""
|
||||
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
echo -e "${BLUE}🚀 Starting MEV Bot service...${NC}"
|
||||
systemctl start mev-bot.service
|
||||
|
||||
# Wait a moment for service to start
|
||||
sleep 3
|
||||
|
||||
# Check status
|
||||
if systemctl is-active --quiet mev-bot.service; then
|
||||
echo -e "${GREEN}✅ MEV Bot service is running${NC}"
|
||||
else
|
||||
echo -e "${YELLOW}⚠️ Service may not be running properly${NC}"
|
||||
echo -e "${YELLOW} Check status with: sudo systemctl status mev-bot${NC}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Display usage information
|
||||
echo ""
|
||||
echo -e "${GREEN}╔════════════════════════════════════════════════════════════╗${NC}"
|
||||
echo -e "${GREEN}║ 🎉 Systemd Service Installation Complete! ║${NC}"
|
||||
echo -e "${GREEN}╚════════════════════════════════════════════════════════════╝${NC}"
|
||||
echo ""
|
||||
echo -e "${BLUE}📋 Systemd Service Commands:${NC}"
|
||||
echo ""
|
||||
echo -e " ${CYAN}sudo systemctl status mev-bot${NC}"
|
||||
echo -e " └─ Check service status"
|
||||
echo ""
|
||||
echo -e " ${CYAN}sudo systemctl start mev-bot${NC}"
|
||||
echo -e " └─ Start the service"
|
||||
echo ""
|
||||
echo -e " ${CYAN}sudo systemctl stop mev-bot${NC}"
|
||||
echo -e " └─ Stop the service"
|
||||
echo ""
|
||||
echo -e " ${CYAN}sudo systemctl restart mev-bot${NC}"
|
||||
echo -e " └─ Restart the service"
|
||||
echo ""
|
||||
echo -e " ${CYAN}sudo systemctl reload mev-bot${NC}"
|
||||
echo -e " └─ Reload (restart container)"
|
||||
echo ""
|
||||
echo -e " ${CYAN}journalctl -u mev-bot -f${NC}"
|
||||
echo -e " └─ View service logs (follow mode)"
|
||||
echo ""
|
||||
echo -e " ${CYAN}sudo systemctl disable mev-bot${NC}"
|
||||
echo -e " └─ Disable auto-start on boot"
|
||||
echo ""
|
||||
echo -e "${BLUE}📊 Docker Commands:${NC}"
|
||||
echo ""
|
||||
echo -e " ${CYAN}docker compose logs -f mev-bot${NC}"
|
||||
echo -e " └─ View container logs"
|
||||
echo ""
|
||||
echo -e " ${CYAN}docker compose ps${NC}"
|
||||
echo -e " └─ Check container status"
|
||||
echo ""
|
||||
echo -e "${GREEN}✅ MEV Bot will now auto-start on system boot${NC}"
|
||||
Reference in New Issue
Block a user