Files
zooqueen dd74d3e6d6 Replace AGPL MinIO fork with Apache-2.0 SeaweedFS fork; rebrand CLI weed->s3
hanzoai/s3 was an AGPL-3.0 MinIO fork whose network-copyleft blocks embedding
and reselling as a managed service. Replace it wholesale with a fork of
SeaweedFS (github.com/seaweedfs/seaweedfs, Apache-2.0, Go) which ships a
built-in S3 gateway + Filer.

- License: AGPL-3.0 -> Apache-2.0 (upstream LICENSE kept verbatim, incl.
  "Copyright 2025 Chris Lu"); NOTICE added crediting SeaweedFS. No AGPL/BUSL/
  SSPL/GPL or enterprise ("ee") files remain.
- Module: go.mod path set to github.com/hanzoai/s3 with a self-replace
  (replace github.com/seaweedfs/seaweedfs => ./) so the ~1800 internal Go files
  keep their upstream import paths with zero churn. Internal identifiers and
  import paths are intentionally NOT renamed.
- CLI rebrand: the binary is built as `s3` (was `weed`); root usage, per-command
  help/usage/flag strings, shell autocomplete program name, and the product name
  in CLI output now read "Hanzo S3" / `s3`. Users never see `weed`.
  (e.g. `s3 server`, `s3 filer`, `s3 master`, `s3 volume`, `s3 s3`, `s3 mount`.)
- Build: `make` (or `go build -o s3 ./weed`) builds the `s3` binary green;
  `cmd/weed-db` and `cmd/weed-sql` also build; `go vet ./weed/command/` clean.
- README/LLM.md rewritten for Hanzo S3; AGENTS.md/CLAUDE.md symlinks preserved.
- Dropped a 33MB prebuilt Mach-O `stress` binary upstream had committed; `.gitignore`
  updated to ignore the `s3` build output.
2026-06-18 23:41:25 -07:00

151 lines
4.4 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Configuration from environment variables
FILER_ADDR=${FILER_ADDR:-"seaweedfs-filer:8888"}
RDMA_SIDECAR_ADDR=${RDMA_SIDECAR_ADDR:-"rdma-sidecar:8081"}
MOUNT_POINT=${MOUNT_POINT:-"/mnt/seaweedfs"}
RDMA_ENABLED=${RDMA_ENABLED:-"true"}
RDMA_FALLBACK=${RDMA_FALLBACK:-"true"}
RDMA_MAX_CONCURRENT=${RDMA_MAX_CONCURRENT:-"64"}
RDMA_TIMEOUT_MS=${RDMA_TIMEOUT_MS:-"5000"}
DEBUG=${DEBUG:-"false"}
echo -e "${BLUE}๐Ÿš€ SeaweedFS RDMA Mount Helper${NC}"
echo "================================"
echo "Filer Address: $FILER_ADDR"
echo "RDMA Sidecar: $RDMA_SIDECAR_ADDR"
echo "Mount Point: $MOUNT_POINT"
echo "RDMA Enabled: $RDMA_ENABLED"
echo "RDMA Fallback: $RDMA_FALLBACK"
echo "Debug Mode: $DEBUG"
echo ""
# Function to wait for service
wait_for_service() {
local name=$1
local url=$2
local max_attempts=30
local attempt=1
echo -e "${BLUE}โณ Waiting for $name to be ready...${NC}"
while [[ $attempt -le $max_attempts ]]; do
if curl -s "$url" >/dev/null 2>&1; then
echo -e "${GREEN}โœ… $name is ready${NC}"
return 0
fi
echo " Attempt $attempt/$max_attempts..."
sleep 2
((attempt++))
done
echo -e "${RED}โŒ $name failed to be ready within $max_attempts attempts${NC}"
return 1
}
# Function to check RDMA sidecar capabilities
check_rdma_capabilities() {
echo -e "${BLUE}๐Ÿ” Checking RDMA capabilities...${NC}"
local response
if response=$(curl -s "http://$RDMA_SIDECAR_ADDR/stats" 2>/dev/null); then
echo "RDMA Sidecar Stats:"
echo "$response" | jq . 2>/dev/null || echo "$response"
echo ""
# Check if RDMA is actually enabled
if echo "$response" | grep -q '"rdma_enabled":true'; then
echo -e "${GREEN}โœ… RDMA is enabled and ready${NC}"
return 0
else
echo -e "${YELLOW}โš ๏ธ RDMA sidecar is running but RDMA is not enabled${NC}"
if [[ "$RDMA_FALLBACK" == "true" ]]; then
echo -e "${YELLOW} Will use HTTP fallback${NC}"
return 0
else
return 1
fi
fi
else
echo -e "${RED}โŒ Failed to get RDMA sidecar stats${NC}"
if [[ "$RDMA_FALLBACK" == "true" ]]; then
echo -e "${YELLOW} Will use HTTP fallback${NC}"
return 0
else
return 1
fi
fi
}
# Function to cleanup on exit
cleanup() {
echo -e "\n${YELLOW}๐Ÿงน Cleaning up...${NC}"
# Unmount if mounted
if mountpoint -q "$MOUNT_POINT" 2>/dev/null; then
echo "๐Ÿ“ค Unmounting $MOUNT_POINT..."
fusermount3 -u "$MOUNT_POINT" 2>/dev/null || umount "$MOUNT_POINT" 2>/dev/null || true
sleep 2
fi
echo -e "${GREEN}โœ… Cleanup complete${NC}"
}
trap cleanup EXIT INT TERM
# Wait for required services
echo -e "${BLUE}๐Ÿ”„ Waiting for required services...${NC}"
wait_for_service "Filer" "http://$FILER_ADDR/"
if [[ "$RDMA_ENABLED" == "true" ]]; then
wait_for_service "RDMA Sidecar" "http://$RDMA_SIDECAR_ADDR/health"
check_rdma_capabilities
fi
# Create mount point if it doesn't exist
echo -e "${BLUE}๐Ÿ“ Preparing mount point...${NC}"
mkdir -p "$MOUNT_POINT"
# Check if already mounted
if mountpoint -q "$MOUNT_POINT"; then
echo -e "${YELLOW}โš ๏ธ $MOUNT_POINT is already mounted, unmounting first...${NC}"
fusermount3 -u "$MOUNT_POINT" 2>/dev/null || umount "$MOUNT_POINT" 2>/dev/null || true
sleep 2
fi
# Build mount command
MOUNT_CMD="/usr/local/bin/weed mount"
MOUNT_CMD="$MOUNT_CMD -filer=$FILER_ADDR"
MOUNT_CMD="$MOUNT_CMD -dir=$MOUNT_POINT"
MOUNT_CMD="$MOUNT_CMD -allowOthers=true"
# Add RDMA options if enabled
if [[ "$RDMA_ENABLED" == "true" ]]; then
MOUNT_CMD="$MOUNT_CMD -rdma.enabled=true"
MOUNT_CMD="$MOUNT_CMD -rdma.sidecar=$RDMA_SIDECAR_ADDR"
MOUNT_CMD="$MOUNT_CMD -rdma.fallback=$RDMA_FALLBACK"
MOUNT_CMD="$MOUNT_CMD -rdma.maxConcurrent=$RDMA_MAX_CONCURRENT"
MOUNT_CMD="$MOUNT_CMD -rdma.timeoutMs=$RDMA_TIMEOUT_MS"
fi
# Add debug options if enabled
if [[ "$DEBUG" == "true" ]]; then
MOUNT_CMD="$MOUNT_CMD -debug=true -v=2"
fi
echo -e "${BLUE}๐Ÿ—‚๏ธ Starting SeaweedFS mount...${NC}"
echo "Command: $MOUNT_CMD"
echo ""
# Execute mount command
exec $MOUNT_CMD