#!/usr/bin/env bash set -e REPO="ugolbck/seofordev" APP="seo" CONFIG_DIR="${HOME}/.seo" CONFIG_FILE="${CONFIG_DIR}/config.yml" INSTALL_DIR="/usr/local/bin" # Detect OS and architecture OS=$(uname | tr '[:upper:]' '[:lower:]') ARCH=$(uname -m) case "$ARCH" in x86_64) ARCH="amd64" ;; arm64|aarch64) ARCH="arm64" ;; *) echo "❌ Unsupported architecture: $ARCH" && exit 1 ;; esac # Helper to check command existence has_cmd() { command -v "$1" >/dev/null 2>&1 } # Ensure minimal Playwright/Chromium libraries on Debian/Ubuntu/WSL if [ "$OS" = "linux" ] && has_cmd apt-get; then echo "🔎 Checking required system libraries for browser automation (Playwright)" # Determine correct ALSA package for this distro (Ubuntu 24.04/Devan: libasound2t64; older: libasound2) ALSA_PKG="libasound2" if has_cmd apt-cache && apt-cache show libasound2t64 >/dev/null 2>&1; then ALSA_PKG="libasound2t64" fi REQ_PKGS=(libnss3 libnspr4 "$ALSA_PKG") MISSING=() for P in "${REQ_PKGS[@]}"; do dpkg -s "$P" >/dev/null 2>&1 || MISSING+=("$P") done if [ ${#MISSING[@]} -gt 0 ]; then echo "đŸ“Ļ Installing missing libraries: ${MISSING[*]}" sudo apt-get update -y sudo apt-get install -y "${MISSING[@]}" else echo "✅ Required libraries already present" fi else if [ "$OS" = "linux" ]; then echo "â„šī¸ Skipping system library installation (apt not found). If you hit Playwright errors, install: libnss3 libnspr4 libasound2" fi fi # Fetch latest version LATEST=$(curl -s https://api.github.com/repos/${REPO}/releases/latest | grep tag_name | cut -d '"' -f 4) TARBALL="seofordev_${OS}_${ARCH}.tar.gz" URL="https://github.com/${REPO}/releases/download/${LATEST}/${TARBALL}" echo "đŸ“Ļ Downloading $APP ($OS/$ARCH) from $URL" TMP_DIR=$(mktemp -d) curl -sL "$URL" -o "$TMP_DIR/$TARBALL" tar -xzf "$TMP_DIR/$TARBALL" -C "$TMP_DIR" chmod +x "$TMP_DIR/${APP}" # Create config if not exists if [ ! -f "$CONFIG_FILE" ]; then echo "âš™ī¸ Creating config file at $CONFIG_FILE" mkdir -p "$CONFIG_DIR" cat < "$CONFIG_FILE" api_key: "" default_port: 3000 default_concurrency: 4 default_max_pages: 0 default_max_depth: 0 default_ignore_patterns: - "/api" - "/admin" EOF echo "✅ Created config file at $CONFIG_FILE" else echo "â„šī¸ Config already exists at $CONFIG_FILE" fi # Move binary (requires sudo) echo "🔐 Installing ${APP} to ${INSTALL_DIR} (you may be prompted for your password)" sudo mv "$TMP_DIR/$APP" "${INSTALL_DIR}/${APP}" sudo chmod +x "${INSTALL_DIR}/${APP}" echo "✅ Installed ${APP} to ${INSTALL_DIR}/${APP}" echo "🚀 All set! Run \`seo\` to get started."