#!/bin/bash # Ryvion DePIN Node Linux Installer # Download and run: curl -sSL https://install.ryvion.com | bash set -e VERSION=${VERSION:-"latest"} HUB_URL=${HUB_URL:-"https://ryvion-hub.fly.dev"} INSTALL_DIR="/opt/ryvion" CONFIG_DIR="$HOME/.ryvion" SERVICE_NAME="ryvion-node" BIND_TOKEN="" UI_PORT="45890" # Colors RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' CYAN='\033[0;36m' NC='\033[0m' echo -e "${CYAN}🚀 Ryvion DePIN Node Linux Installer${NC}" echo -e "${CYAN}====================================${NC}" echo "" # Check if running as root if [[ $EUID -eq 0 ]]; then echo -e "${RED}❌ This script should not be run as root for security reasons${NC}" echo -e "${YELLOW}Please run as a regular user. The script will ask for sudo when needed.${NC}" exit 1 fi # Detect architecture ARCH=$(uname -m) case $ARCH in x86_64) BINARY_ARCH="amd64" ;; aarch64|arm64) BINARY_ARCH="arm64" ;; *) echo -e "${RED}❌ Unsupported architecture: $ARCH${NC}"; exit 1 ;; esac echo -e "${BLUE}â„šī¸ Detected architecture: $ARCH${NC}" # Check system requirements echo -e "${YELLOW}🔍 Checking system requirements...${NC}" # Check memory MEMORY_KB=$(grep MemTotal /proc/meminfo 2>/dev/null | awk '{print $2}' || echo "4194304") MEMORY_GB=$((MEMORY_KB / 1024 / 1024)) if [[ $MEMORY_GB -lt 4 ]]; then echo -e "${YELLOW}âš ī¸ Low memory detected: ${MEMORY_GB}GB (minimum 4GB recommended)${NC}" else echo -e "${GREEN}✅ Memory check passed: ${MEMORY_GB}GB${NC}" fi # Check for GPU if command -v nvidia-smi &> /dev/null; then GPU_INFO=$(nvidia-smi --query-gpu=name,memory.total --format=csv,noheader,nounits | head -1) echo -e "${GREEN}🎮 NVIDIA GPU detected: $GPU_INFO${NC}" elif command -v rocm-smi &> /dev/null; then echo -e "${GREEN}🎮 AMD GPU detected${NC}" else echo -e "${BLUE}đŸ’ģ No dedicated GPU detected (CPU-only mode)${NC}" fi # Create directories echo -e "${YELLOW}📁 Creating directories...${NC}" sudo mkdir -p "$INSTALL_DIR" mkdir -p "$CONFIG_DIR" # Download and install binary echo -e "${YELLOW}đŸ“Ĩ Downloading Ryvion Node binary...${NC}" if [ "$BINARY_ARCH" = "arm64" ]; then DOWNLOAD_URL="${HUB_URL}/download/linux/arm64" else DOWNLOAD_URL="${HUB_URL}/download/linux/binary" fi if command -v curl &> /dev/null; then curl -fSL "$DOWNLOAD_URL" | sudo tar -xz -C "$INSTALL_DIR" elif command -v wget &> /dev/null; then wget -O- "$DOWNLOAD_URL" | sudo tar -xz -C "$INSTALL_DIR" else echo -e "${RED}❌ Neither curl nor wget found. Please install one of them.${NC}" exit 1 fi sudo chmod +x "$INSTALL_DIR/ryvion-node" sudo ln -sf "$INSTALL_DIR/ryvion-node" /usr/local/bin/ryvion-node echo -e "${GREEN}✅ Binary installed successfully${NC}" # Create configuration echo -e "${YELLOW}âš™ī¸ Creating configuration...${NC}" if [[ -n "$BIND_TOKEN" ]]; then cat > "$CONFIG_DIR/config.json" << EOF { "hub_url": "$HUB_URL", "device_type": "auto", "log_level": "info", "log_file": "$CONFIG_DIR/node.log", "bind_token": "$BIND_TOKEN" } EOF else cat > "$CONFIG_DIR/config.json" << EOF { "hub_url": "$HUB_URL", "device_type": "auto", "log_level": "info", "log_file": "$CONFIG_DIR/node.log" } EOF fi BIND_ENV="" if [[ -n "$BIND_TOKEN" ]]; then BIND_ENV="Environment=RYV_BIND_TOKEN=$BIND_TOKEN" fi # Install systemd service echo -e "${YELLOW}🔧 Installing systemd service...${NC}" sudo tee "/etc/systemd/system/$SERVICE_NAME.service" > /dev/null << EOF [Unit] Description=Ryvion DePIN Node After=network.target Wants=network.target [Service] Type=simple User=$USER WorkingDirectory=$CONFIG_DIR Environment=RYV_HUB_URL=$HUB_URL Environment=RYV_UI_PORT=$UI_PORT $BIND_ENV ExecStart=$INSTALL_DIR/ryvion-node Restart=always RestartSec=10 StandardOutput=journal StandardError=journal SyslogIdentifier=ryvion-node # Resource limits LimitNOFILE=65536 MemoryMax=8G [Install] WantedBy=multi-user.target EOF # Enable and start service sudo systemctl daemon-reload sudo systemctl enable "$SERVICE_NAME" sudo systemctl start "$SERVICE_NAME" sleep 3 if systemctl is-active --quiet "$SERVICE_NAME"; then echo -e "${GREEN}🎉 Ryvion Node started successfully!${NC}" else echo -e "${YELLOW}âš ī¸ Service may have issues. Check logs with: journalctl -u $SERVICE_NAME -f${NC}" fi if command -v curl >/dev/null 2>&1; then for _ in 1 2 3 4 5; do if curl -fsS "http://127.0.0.1:$UI_PORT/healthz" >/dev/null 2>&1; then echo -e "${GREEN}✅ Local operator API is reachable on http://127.0.0.1:$UI_PORT${NC}" break fi sleep 1 done fi # Create management script echo -e "${YELLOW}📝 Creating management script...${NC}" sudo tee "/usr/local/bin/ryvion-ctl" > /dev/null << 'EOF' #!/bin/bash # Ryvion Node Control Script SERVICE_NAME="ryvion-node" case "$1" in start) echo "🚀 Starting Ryvion node..." sudo systemctl start "$SERVICE_NAME" ;; stop) echo "🛑 Stopping Ryvion node..." sudo systemctl stop "$SERVICE_NAME" ;; restart) echo "🔄 Restarting Ryvion node..." sudo systemctl restart "$SERVICE_NAME" ;; status) systemctl status "$SERVICE_NAME" ;; logs) journalctl -u "$SERVICE_NAME" -f ;; update) echo "âŦ†ī¸ Updating Ryvion node..." curl -sSL https://install.ryvion.com | bash ;; *) echo "Usage: $0 {start|stop|restart|status|logs|update}" exit 1 ;; esac EOF sudo chmod +x "/usr/local/bin/ryvion-ctl" echo "" echo -e "${CYAN}========================================${NC}" echo -e "${CYAN}🎉 Ryvion DePIN Node Installation Complete!${NC}" echo -e "${CYAN}========================================${NC}" echo "" echo -e "${YELLOW}Management commands:${NC}" echo -e " ${BLUE}ryvion-ctl start${NC} - Start the node" echo -e " ${BLUE}ryvion-ctl stop${NC} - Stop the node" echo -e " ${BLUE}ryvion-ctl status${NC} - Check node status" echo -e " ${BLUE}ryvion-ctl logs${NC} - View node logs" echo -e " ${BLUE}ryvion-ctl update${NC} - Update to latest version" echo "" echo -e "${YELLOW}Next steps:${NC}" echo -e "1. Node will automatically detect your hardware and start mining" echo -e "2. Monitor your node: ${BLUE}ryvion-ctl status${NC}" echo -e "3. View earnings at: ${BLUE}https://ryvion.com/dashboard${NC}" echo -e "4. Join our community: ${BLUE}https://discord.gg/ryvion${NC}" echo "" echo -e "${GREEN}✨ Your Linux machine is now part of the Ryvion DePIN network!${NC}"