Ctrl K
ComunidadGuías…

bin/setup

Rama master · réplica de lectura del repositorio original.

Archivo original ↗Preguntar a KiBot
#!/bin/sh

set -eu

SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd -P)
cd "$SCRIPT_DIR/.."

open_url() {
  url="$1"

  if command -v xdg-open >/dev/null 2>&1; then
    xdg-open "$url" >/dev/null 2>&1 &
    return
  fi

  if command -v open >/dev/null 2>&1; then
    open "$url"
    return
  fi

  if command -v x-www-browser >/dev/null 2>&1; then
    x-www-browser "$url" >/dev/null 2>&1 &
    return
  fi

  echo "🚀 Open this URL in your browser to complete setup: $url"
}

echo "🌟 Welcome to the ShellHub Setup Script"
echo ""

SERVICES=$(docker compose ps -q | grep -v INFO: | xargs docker inspect -f '{{.State.Running}}' 2>/dev/null | grep -c 'true' || true)
[ "$SERVICES" -le 0 ] && { echo "🚫 ERROR: ShellHub is not running. Exiting."; exit 1; }

if curl -s http://localhost/info | grep -q '"setup":true'; then
  echo "✅ Setup has already been completed. No further action is required."
  exit 0
fi

echo "📋 This script will open the setup URL for your ShellHub instance."
echo "❗ Important: The ShellHub instance cannot be on localhost. Please ensure you provide a valid public IP address or hostname."
echo ""

URL="http://localhost/setup"

echo "🔗 Generated Setup URL: $URL"
open_url "$URL"

echo ""
echo "✅ Please ensure your ShellHub server is running and accessible from an external address."