#!/bin/bash # # RinHash Miner - Remote Docker Setup Script # This script helps set up remote Docker access for building from another machine # set -e echo "๐Ÿณ RinHash Miner - Remote Docker Setup" echo "=====================================" echo "" # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color # Check if running as root if [[ $EUID -eq 0 ]]; then echo -e "${RED}โŒ Please do not run this script as root!${NC}" echo "Run as a regular user with sudo access." exit 1 fi # Check if Docker is installed if ! command -v docker &> /dev/null; then echo -e "${RED}โŒ Docker is not installed!${NC}" echo "Please install Docker first:" echo " sudo apt update && sudo apt install -y docker.io" exit 1 fi echo -e "${BLUE}๐Ÿ“‹ Checking current Docker status...${NC}" sudo systemctl status docker --no-pager -l || true echo "" echo -e "${BLUE}๐Ÿ”ง Setting up Docker access...${NC}" # Add user to docker group echo "Adding user to docker group..." sudo usermod -aG docker $USER # Enable and start Docker service echo "Enabling and starting Docker service..." sudo systemctl enable docker sudo systemctl start docker # Test Docker access echo "" echo -e "${BLUE}๐Ÿงช Testing Docker access...${NC}" if docker ps &> /dev/null; then echo -e "${GREEN}โœ… Docker access working!${NC}" else echo -e "${YELLOW}โš ๏ธ Docker access may require logout/login or 'newgrp docker'${NC}" fi # Show Docker version and info echo "" echo -e "${BLUE}๐Ÿ“Š Docker Information:${NC}" docker --version docker system info --format "Server Version: {{.ServerVersion}}\nOperating System: {{.OperatingSystem}}\nArchitecture: {{.Architecture}}" # Test the build container echo "" echo -e "${BLUE}๐Ÿš€ Testing RinHash build container...${NC}" if docker run --rm cpuminer-windows-builder echo "RinHash build environment ready!" 2>/dev/null; then echo -e "${GREEN}โœ… Build container working!${NC}" else echo -e "${YELLOW}โš ๏ธ Build container not found. You may need to pull it:${NC}" echo " docker pull cpuminer-windows-builder" fi echo "" echo -e "${GREEN}๐ŸŽ‰ Setup Complete!${NC}" echo "" echo -e "${BLUE}๐Ÿ“– Next Steps:${NC}" echo "" echo "1. ${YELLOW}For SSH tunneling (Recommended - Most Secure):${NC}" echo " From your local machine:" echo " ssh -L localhost:2375:/var/run/docker.sock $USER@$(hostname -I | awk '{print $1}')" echo " export DOCKER_HOST=tcp://localhost:2375" echo "" echo "2. ${YELLOW}For Docker contexts:${NC}" echo " docker context create remote-build --docker \"host=ssh://$USER@$(hostname -I | awk '{print $1}')\"" echo " docker context use remote-build" echo "" echo "3. ${YELLOW}For VS Code Remote Development:${NC}" echo " - Install VS Code extensions: Docker, Remote-SSH" echo " - Use Command Palette: Remote-SSH: Connect to Host" echo " - Run build tasks from VS Code" echo "" echo "4. ${YELLOW}Test remote access:${NC}" echo " docker run --rm cpuminer-windows-builder echo 'Remote Docker working!'" echo "" echo -e "${BLUE}๐Ÿ“ Build Commands:${NC}" echo " ./build-windows-smart.sh # Smart build with curl detection" echo " ./build-windows.sh # Manual build" echo "" echo -e "${GREEN}Happy building! ๐Ÿš€${NC}"