#!/usr/bin/env bash set -e # Colors RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color REPO_URL="https://code.foss.global/serve.zone/isocreator" INSTALL_DIR="/opt/isocreator" BIN_LINK="/usr/local/bin/isocreator" VERSION="latest" # Parse arguments while [[ $# -gt 0 ]]; do case $1 in --version) VERSION="$2" shift 2 ;; --install-dir) INSTALL_DIR="$2" shift 2 ;; -h|--help) echo "Usage: $0 [OPTIONS]" echo "" echo "Options:" echo " --version VERSION Install specific version (default: latest)" echo " --install-dir DIR Installation directory (default: /opt/isocreator)" echo " -h, --help Show this help message" exit 0 ;; *) echo -e "${RED}Unknown option: $1${NC}" exit 1 ;; esac done echo -e "${BLUE}🚀 isocreator installer${NC}" echo "" # Detect platform OS=$(uname -s | tr '[:upper:]' '[:lower:]') ARCH=$(uname -m) case "$OS" in linux) PLATFORM="linux" ;; darwin) PLATFORM="macos" ;; *) echo -e "${RED}❌ Unsupported operating system: $OS${NC}" exit 1 ;; esac case "$ARCH" in x86_64|amd64) ARCH="x64" ;; aarch64|arm64) ARCH="arm64" ;; *) echo -e "${RED}❌ Unsupported architecture: $ARCH${NC}" exit 1 ;; esac BINARY_NAME="isocreator-${PLATFORM}-${ARCH}" echo -e "${BLUE}📋 Detected platform: ${PLATFORM}-${ARCH}${NC}" # Get version if [ "$VERSION" == "latest" ]; then echo -e "${BLUE}🔍 Fetching latest version...${NC}" VERSION=$(curl -sSL "${REPO_URL}/raw/branch/main/deno.json" | grep -o '"version": "[^"]*' | cut -d'"' -f4) if [ -z "$VERSION" ]; then echo -e "${YELLOW}⚠️ Could not fetch latest version, using fallback${NC}" VERSION="1.0.0" fi fi echo -e "${GREEN}📦 Version: v${VERSION}${NC}" # Download URL (try release first, fallback to raw branch) RELEASE_URL="${REPO_URL}/releases/download/v${VERSION}/${BINARY_NAME}" FALLBACK_URL="${REPO_URL}/raw/branch/main/dist/binaries/${BINARY_NAME}" echo -e "${BLUE}⬇️ Downloading binary...${NC}" # Try release URL first if curl -fsSL -o "/tmp/${BINARY_NAME}" "$RELEASE_URL" 2>/dev/null; then echo -e "${GREEN}✅ Downloaded from release${NC}" else echo -e "${YELLOW}⚠️ Release not found, trying fallback...${NC}" if curl -fsSL -o "/tmp/${BINARY_NAME}" "$FALLBACK_URL"; then echo -e "${GREEN}✅ Downloaded from fallback${NC}" else echo -e "${RED}❌ Failed to download binary${NC}" exit 1 fi fi # Create installation directory echo -e "${BLUE}📁 Creating installation directory...${NC}" mkdir -p "$INSTALL_DIR" # Move binary to installation directory echo -e "${BLUE}📦 Installing binary...${NC}" mv "/tmp/${BINARY_NAME}" "${INSTALL_DIR}/isocreator" chmod +x "${INSTALL_DIR}/isocreator" # Create symlink echo -e "${BLUE}🔗 Creating symlink...${NC}" if [ -L "$BIN_LINK" ]; then rm "$BIN_LINK" fi ln -s "${INSTALL_DIR}/isocreator" "$BIN_LINK" echo "" echo -e "${GREEN}✅ isocreator installed successfully!${NC}" echo "" echo -e "${BLUE}📍 Installation location: ${INSTALL_DIR}/isocreator${NC}" echo -e "${BLUE}🔗 Symlink created: ${BIN_LINK}${NC}" echo "" echo -e "${GREEN}💡 Try running: isocreator --help${NC}" echo "" echo -e "${YELLOW}⚠️ Note: isocreator requires the following system tools:${NC}" echo -e " - xorriso (for ISO manipulation)" echo -e " - isohybrid (for USB-bootable ISOs)" echo -e "" echo -e "${BLUE}Install on Ubuntu/Debian:${NC}" echo -e " sudo apt install xorriso syslinux-utils" echo -e "" echo -e "${BLUE}Install on macOS:${NC}" echo -e " brew install xorriso syslinux"