#!/bin/bash # # EconV1 Node - One-Line Installation Script # Usage: curl -sSL https://apt.economy1.cloud/install.sh | sudo bash # set -e # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color # Configuration REPO_URL="https://apt.economy1.cloud" PACKAGE_NAME="econ-v1" echo -e "${GREEN}╔════════════════════════════════════════════════╗${NC}" echo -e "${GREEN}║ EconV1 Node Installation Script ║${NC}" echo -e "${GREEN}╚════════════════════════════════════════════════╝${NC}" echo "" # Check if running as root if [ "$EUID" -ne 0 ]; then echo -e "${RED}Error: This script must be run as root (use sudo)${NC}" exit 1 fi # Detect architecture ARCH=$(dpkg --print-architecture) echo -e "${GREEN}✓${NC} Detected architecture: ${ARCH}" # Map architecture to package suffix case "$ARCH" in amd64) PACKAGE_ARCH="amd64" ;; arm64|aarch64) PACKAGE_ARCH="arm64" ;; *) echo -e "${RED}Error: Unsupported architecture: ${ARCH}${NC}" echo "Supported architectures: amd64, arm64" exit 1 ;; esac # Get latest version via APT worker echo -e "${YELLOW}→${NC} Fetching latest version..." LATEST_VERSION=$(curl -sSL "${REPO_URL}/api/latest" | grep '"version":' | sed -E 's/.*"([^"]+)".*/\1/') if [ -z "$LATEST_VERSION" ]; then echo -e "${RED}Error: Could not fetch latest version${NC}" exit 1 fi VERSION_NUMBER=${LATEST_VERSION#v} # Remove 'v' prefix echo -e "${GREEN}✓${NC} Latest version: ${LATEST_VERSION}" # Download package PACKAGE_FILE="${PACKAGE_NAME}_${VERSION_NUMBER}_${PACKAGE_ARCH}.deb" DOWNLOAD_URL="${REPO_URL}/releases/download/${LATEST_VERSION}/${PACKAGE_FILE}" echo -e "${YELLOW}→${NC} Downloading ${PACKAGE_FILE}..." if ! curl -sSL -f -o "/tmp/${PACKAGE_FILE}" "${DOWNLOAD_URL}"; then echo -e "${RED}Error: Failed to download package${NC}" echo "URL: ${DOWNLOAD_URL}" exit 1 fi echo -e "${GREEN}✓${NC} Package downloaded" # Install package echo -e "${YELLOW}→${NC} Installing package..." if dpkg -i "/tmp/${PACKAGE_FILE}" 2>/dev/null; then echo -e "${GREEN}✓${NC} Package installed successfully" else # If dpkg fails, try to fix dependencies echo -e "${YELLOW}→${NC} Installing dependencies..." apt-get update -qq apt-get install -f -y echo -e "${GREEN}✓${NC} Dependencies installed" fi # Clean up rm -f "/tmp/${PACKAGE_FILE}" # Add APT repository for automatic updates echo -e "${YELLOW}→${NC} Adding APT repository for automatic updates..." # Check if gnupg is installed if ! command -v gpg &> /dev/null; then echo -e "${YELLOW}→${NC} Installing gnupg..." apt-get update -qq apt-get install -y -qq gnupg fi # Add GPG key using modern method if curl -fsSL "${REPO_URL}/KEY.gpg" | gpg --dearmor -o /usr/share/keyrings/econ-v1.gpg 2>/dev/null; then echo -e "${GREEN}✓${NC} GPG key added" # Add repository echo "deb [signed-by=/usr/share/keyrings/econ-v1.gpg] ${REPO_URL}/ stable main" > /etc/apt/sources.list.d/econ-v1.list echo -e "${GREEN}✓${NC} APT repository configured" # Update package lists if apt-get update -qq 2>/dev/null; then echo -e "${GREEN}✓${NC} Package lists updated" echo -e "${GREEN}✓${NC} Future updates available via: ${GREEN}sudo apt update && sudo apt upgrade econ-v1${NC}" else echo -e "${YELLOW}⚠${NC} Could not update package lists" fi else echo -e "${YELLOW}⚠${NC} Could not add APT repository (updates will need manual installation)" fi # Check if service is available if systemctl list-unit-files | grep -q "econ-v1.service"; then echo -e "${YELLOW}→${NC} Configuring service..." # Enable service systemctl enable econ-v1 >/dev/null 2>&1 || true # Start service if systemctl start econ-v1 2>/dev/null; then echo -e "${GREEN}✓${NC} Service started" sleep 2 # Check service status if systemctl is-active --quiet econ-v1; then echo -e "${GREEN}✓${NC} Service is running" else echo -e "${YELLOW}⚠${NC} Service installed but not running" echo " Check logs: journalctl -u econ-v1 -f" fi else echo -e "${YELLOW}⚠${NC} Could not start service automatically" echo " Start manually: sudo systemctl start econ-v1" fi fi # Installation complete echo "" echo -e "${GREEN}╔════════════════════════════════════════════════╗${NC}" echo -e "${GREEN}║ Installation completed successfully! ║${NC}" echo -e "${GREEN}╚════════════════════════════════════════════════╝${NC}" echo "" # Get local IP address LOCAL_IP=$(hostname -I | awk '{print $1}') API_PORT=80 echo -e "📦 Installed version: ${GREEN}${VERSION_NUMBER}${NC}" echo -e "🏠 Access web interface at:" echo -e " • Local: ${GREEN}http://localhost:${API_PORT}${NC}" echo -e " • Network: ${GREEN}http://${LOCAL_IP}:${API_PORT}${NC}" echo "" echo -e "📋 Useful commands:" echo -e " • Check status: ${GREEN}sudo systemctl status econ-v1${NC}" echo -e " • View logs: ${GREEN}journalctl -u econ-v1 -f${NC}" echo -e " • Stop service: ${GREEN}sudo systemctl stop econ-v1${NC}" echo -e " • Start service: ${GREEN}sudo systemctl start econ-v1${NC}" echo "" echo -e "📖 Documentation: https://github.com/econ-v1/node-releases" echo -e "🐛 Report issues: https://github.com/econ-v1/node-releases/issues" echo "" echo -e "✅ APT repository has been configured for automatic updates" echo -e " Update in the future with: ${GREEN}sudo apt update && sudo apt upgrade econ-v1${NC}" echo "" exit 0