install.sh
1 #!/bin/bash 2 # ACDC Botnet - Systemd Service Installation Script 3 4 set -e 5 6 # Colors for output 7 RED='\033[0;31m' 8 GREEN='\033[0;32m' 9 YELLOW='\033[1;33m' 10 NC='\033[0m' # No Color 11 12 # Check if running as root 13 if [[ $EUID -ne 0 ]]; then 14 echo -e "${RED}Error: This script must be run as root${NC}" 15 echo "Usage: sudo ./install.sh" 16 exit 1 17 fi 18 19 echo -e "${GREEN}ACDC Botnet - Systemd Service Installation${NC}" 20 echo "==============================================" 21 echo "" 22 23 # 1. Install binary (if not already present) 24 if [[ ! -f /usr/local/bin/acdc-botnet ]]; then 25 echo -e "${YELLOW}Warning: /usr/local/bin/acdc-botnet not found${NC}" 26 echo "Please build and install the binary first:" 27 echo " cd /home/devops/working-repos/acdc-botnet" 28 echo " cargo build --release" 29 echo " sudo cp target/release/acdc-botnet /usr/local/bin/" 30 echo " sudo chmod +x /usr/local/bin/acdc-botnet" 31 echo "" 32 read -p "Continue anyway? (y/N) " -n 1 -r 33 echo 34 if [[ ! $REPLY =~ ^[Yy]$ ]]; then 35 exit 1 36 fi 37 fi 38 39 # 2. Create configuration directory 40 echo -e "${GREEN}Creating configuration directory...${NC}" 41 mkdir -p /etc/acdc-botnet 42 mkdir -p /var/lib/acdc-botnet/checkpoints 43 mkdir -p /opt/acdc-botnet 44 45 # Set proper ownership (assuming 'devops' user exists) 46 if id "devops" &>/dev/null; then 47 chown -R devops:devops /var/lib/acdc-botnet 48 chown -R devops:devops /opt/acdc-botnet 49 echo " ✓ Set ownership to devops:devops" 50 else 51 echo -e "${YELLOW} Warning: 'devops' user not found, using root ownership${NC}" 52 fi 53 54 # 3. Copy service files 55 echo -e "${GREEN}Installing systemd service files...${NC}" 56 cp acdc-botnet-coordinator.service /etc/systemd/system/ 57 cp acdc-botnet-worker@.service /etc/systemd/system/ 58 echo " ✓ Coordinator service installed" 59 echo " ✓ Worker template service installed" 60 61 # 4. Create example worker configurations 62 echo -e "${GREEN}Creating example worker configurations...${NC}" 63 64 # Worker 1 (default configuration) 65 cat > /etc/acdc-botnet/worker-1.conf <<EOF 66 # Worker 1 - Default Configuration 67 COORDINATOR_ADDR=localhost:50051 68 WORKER_ID=worker-1 69 MAX_BOTS=300 70 CAPABILITIES=trader,user,governor 71 CPU_QUOTA=80% 72 MEMORY_MAX=16G 73 EOF 74 75 # Worker 2 (lighter configuration for co-located validator) 76 cat > /etc/acdc-botnet/worker-2.conf <<EOF 77 # Worker 2 - Light Configuration (for nodes running validators) 78 COORDINATOR_ADDR=localhost:50051 79 WORKER_ID=worker-2 80 MAX_BOTS=150 81 CAPABILITIES=trader,user 82 CPU_QUOTA=40% 83 MEMORY_MAX=8G 84 EOF 85 86 echo " ✓ Created /etc/acdc-botnet/worker-1.conf" 87 echo " ✓ Created /etc/acdc-botnet/worker-2.conf" 88 89 # 5. Reload systemd daemon 90 echo -e "${GREEN}Reloading systemd daemon...${NC}" 91 systemctl daemon-reload 92 echo " ✓ Systemd daemon reloaded" 93 94 echo "" 95 echo -e "${GREEN}Installation complete!${NC}" 96 echo "" 97 echo "Next steps:" 98 echo "" 99 echo "1. Start the coordinator:" 100 echo " sudo systemctl start acdc-botnet-coordinator" 101 echo " sudo systemctl enable acdc-botnet-coordinator" 102 echo "" 103 echo "2. Start worker instance(s):" 104 echo " sudo systemctl start acdc-botnet-worker@1" 105 echo " sudo systemctl enable acdc-botnet-worker@1" 106 echo "" 107 echo " (Optional) Start additional workers:" 108 echo " sudo systemctl start acdc-botnet-worker@2" 109 echo " sudo systemctl enable acdc-botnet-worker@2" 110 echo "" 111 echo "3. Check status:" 112 echo " sudo systemctl status acdc-botnet-coordinator" 113 echo " sudo systemctl status acdc-botnet-worker@1" 114 echo "" 115 echo "4. View logs:" 116 echo " sudo journalctl -u acdc-botnet-coordinator -f" 117 echo " sudo journalctl -u acdc-botnet-worker@1 -f" 118 echo "" 119 echo "5. Monitor resource usage:" 120 echo " systemd-cgtop" 121 echo "" 122 echo "Configuration files:" 123 echo " - Coordinator: /etc/systemd/system/acdc-botnet-coordinator.service" 124 echo " - Worker template: /etc/systemd/system/acdc-botnet-worker@.service" 125 echo " - Worker configs: /etc/acdc-botnet/worker-*.conf" 126 echo "" 127 echo "Data directories:" 128 echo " - Checkpoints: /var/lib/acdc-botnet/checkpoints" 129 echo " - Working dir: /opt/acdc-botnet" 130 echo ""