- Enhanced moebius ring logo design in Blender - Updated Docker Compose for website-only deployment with improved config - Enhanced teaser layout with updated branding integration - Added installation and setup documentation - Consolidated planning and reports documentation - Updated gitignore to exclude Next.js build artifacts and archives 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
324 lines
7.6 KiB
Bash
Executable File
324 lines
7.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Minimal BZZZ Binary Builder
|
|
# Creates a basic BZZZ binary that can be distributed
|
|
|
|
set -e
|
|
|
|
# Colors
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
RED='\033[0;31m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m'
|
|
|
|
log_info() { echo -e "${GREEN}✓${NC} $1"; }
|
|
log_warn() { echo -e "${YELLOW}⚠${NC} $1"; }
|
|
log_error() { echo -e "${RED}✗${NC} $1"; }
|
|
log_step() { echo -e "${BLUE}▶${NC} $1"; }
|
|
|
|
# Configuration
|
|
BZZZ_SOURCE="$HOME/chorus/project-queues/active/BZZZ"
|
|
BUILD_DIR="$HOME/chorus/releases/bzzz/latest"
|
|
VERSION="${VERSION:-$(date +%Y%m%d-%H%M%S)}"
|
|
|
|
# Create minimal main.go that avoids import cycles
|
|
create_minimal_main() {
|
|
local temp_dir="$1"
|
|
|
|
cat > "$temp_dir/main.go" << 'EOF'
|
|
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"log"
|
|
"net/http"
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
"time"
|
|
)
|
|
|
|
var (
|
|
version = "dev"
|
|
port = flag.String("port", "8080", "API port")
|
|
host = flag.String("host", "0.0.0.0", "API host")
|
|
showVersion = flag.Bool("version", false, "Show version")
|
|
)
|
|
|
|
func main() {
|
|
flag.Parse()
|
|
|
|
if *showVersion {
|
|
fmt.Printf("BZZZ P2P Task Coordination System v%s\n", version)
|
|
return
|
|
}
|
|
|
|
log.Printf("🐝 BZZZ P2P Task Coordination System v%s", version)
|
|
log.Printf("Starting API server on %s:%s", *host, *port)
|
|
|
|
// Basic HTTP server
|
|
mux := http.NewServeMux()
|
|
|
|
// Health check endpoint
|
|
mux.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.WriteHeader(http.StatusOK)
|
|
fmt.Fprintf(w, `{"status":"ok","service":"bzzz","version":"%s","timestamp":"%s"}`,
|
|
version, time.Now().UTC().Format(time.RFC3339))
|
|
})
|
|
|
|
// Status endpoint
|
|
mux.HandleFunc("/api/agent/status", func(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.WriteHeader(http.StatusOK)
|
|
hostname, _ := os.Hostname()
|
|
fmt.Fprintf(w, `{
|
|
"status":"active",
|
|
"hostname":"%s",
|
|
"version":"%s",
|
|
"capabilities":["coordination","p2p"],
|
|
"models":[],
|
|
"uptime":"%s"
|
|
}`, hostname, version, time.Since(time.Now()).String())
|
|
})
|
|
|
|
// Basic info endpoint
|
|
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "text/html")
|
|
fmt.Fprintf(w, `
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head><title>BZZZ P2P System</title></head>
|
|
<body>
|
|
<h1>🐝 BZZZ P2P Task Coordination System</h1>
|
|
<p>Version: %s</p>
|
|
<p>Status: <a href="/health">Health Check</a></p>
|
|
<p>API: <a href="/api/agent/status">Agent Status</a></p>
|
|
</body>
|
|
</html>`, version)
|
|
})
|
|
|
|
server := &http.Server{
|
|
Addr: *host + ":" + *port,
|
|
Handler: mux,
|
|
}
|
|
|
|
// Graceful shutdown
|
|
go func() {
|
|
sigChan := make(chan os.Signal, 1)
|
|
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
|
|
<-sigChan
|
|
|
|
log.Println("Shutting down BZZZ...")
|
|
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
|
defer cancel()
|
|
|
|
if err := server.Shutdown(ctx); err != nil {
|
|
log.Printf("Server shutdown error: %v", err)
|
|
}
|
|
}()
|
|
|
|
log.Printf("BZZZ ready at http://%s:%s", *host, *port)
|
|
|
|
if err := server.ListenAndServe(); err != http.ErrServerClosed {
|
|
log.Fatalf("Server error: %v", err)
|
|
}
|
|
|
|
log.Println("BZZZ stopped")
|
|
}
|
|
EOF
|
|
|
|
cat > "$temp_dir/go.mod" << EOF
|
|
module github.com/anthonyrawlins/bzzz
|
|
|
|
go 1.21
|
|
|
|
require (
|
|
// No external dependencies to avoid import cycles
|
|
)
|
|
EOF
|
|
|
|
log_info "Created minimal main.go"
|
|
}
|
|
|
|
# Build minimal BZZZ
|
|
build_minimal_bzzz() {
|
|
log_step "Building minimal BZZZ binaries..."
|
|
|
|
# Create temporary build directory
|
|
local temp_dir=$(mktemp -d)
|
|
|
|
# Create minimal Go files
|
|
create_minimal_main "$temp_dir"
|
|
|
|
cd "$temp_dir"
|
|
|
|
# Build for different platforms
|
|
local platforms=(
|
|
"linux/amd64"
|
|
"linux/arm64"
|
|
"linux/arm"
|
|
"darwin/amd64"
|
|
"darwin/arm64"
|
|
)
|
|
|
|
mkdir -p "$BUILD_DIR"
|
|
|
|
for platform in "${platforms[@]}"; do
|
|
local os="${platform%/*}"
|
|
local arch="${platform#*/}"
|
|
|
|
log_step "Building for $os/$arch..."
|
|
|
|
local output_name="bzzz-$os-$arch"
|
|
local output_path="$BUILD_DIR/$output_name"
|
|
|
|
export GOOS="$os"
|
|
export GOARCH="$arch"
|
|
export CGO_ENABLED=0
|
|
|
|
if go build -ldflags="-s -w -X main.version=$VERSION" -o "$output_path" .; then
|
|
log_info "Built $output_name"
|
|
else
|
|
log_error "Failed to build $output_name"
|
|
fi
|
|
done
|
|
|
|
# Reset environment
|
|
unset GOOS GOARCH CGO_ENABLED
|
|
|
|
# Cleanup
|
|
rm -rf "$temp_dir"
|
|
|
|
log_info "Minimal BZZZ binaries built"
|
|
}
|
|
|
|
# Copy support files
|
|
copy_support_files() {
|
|
log_step "Copying support files..."
|
|
|
|
# Create service file
|
|
cat > "$BUILD_DIR/bzzz.service" << EOF
|
|
[Unit]
|
|
Description=BZZZ P2P Task Coordination System
|
|
Documentation=https://chorus.services/docs/bzzz
|
|
After=network.target
|
|
Wants=network.target
|
|
|
|
[Service]
|
|
Type=simple
|
|
User=PLACEHOLDER_USER
|
|
Group=PLACEHOLDER_USER
|
|
WorkingDirectory=PLACEHOLDER_BZZZ_DIR
|
|
ExecStart=PLACEHOLDER_BZZZ_DIR/bzzz
|
|
Restart=always
|
|
RestartSec=10
|
|
KillMode=mixed
|
|
KillSignal=SIGTERM
|
|
TimeoutStopSec=30
|
|
|
|
# Environment variables
|
|
Environment=HOME=PLACEHOLDER_HOME
|
|
Environment=USER=PLACEHOLDER_USER
|
|
|
|
# Logging
|
|
StandardOutput=journal
|
|
StandardError=journal
|
|
SyslogIdentifier=bzzz
|
|
|
|
# Security settings
|
|
NoNewPrivileges=true
|
|
PrivateTmp=true
|
|
ProtectSystem=strict
|
|
ProtectHome=false
|
|
ReadWritePaths=PLACEHOLDER_BZZZ_DIR
|
|
|
|
# Resource limits
|
|
LimitNOFILE=65536
|
|
LimitNPROC=4096
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
EOF
|
|
|
|
# Create install script
|
|
cat > "$BUILD_DIR/install-service.sh" << 'EOF'
|
|
#!/bin/bash
|
|
|
|
# BZZZ Service Installation Script
|
|
set -e
|
|
|
|
echo "🐝 Installing BZZZ P2P Task Coordination Service..."
|
|
|
|
if [ "$EUID" -ne 0 ]; then
|
|
echo "❌ This script must be run as root or with sudo"
|
|
exit 1
|
|
fi
|
|
|
|
BZZZ_DIR="$(pwd)"
|
|
SERVICE_FILE="$BZZZ_DIR/bzzz.service"
|
|
SYSTEMD_DIR="/etc/systemd/system"
|
|
|
|
# Replace placeholders in service file
|
|
sed -i "s|PLACEHOLDER_USER|$SUDO_USER|g" "$SERVICE_FILE"
|
|
sed -i "s|PLACEHOLDER_HOME|$(eval echo ~$SUDO_USER)|g" "$SERVICE_FILE"
|
|
sed -i "s|PLACEHOLDER_BZZZ_DIR|$BZZZ_DIR|g" "$SERVICE_FILE"
|
|
|
|
chmod +x "$BZZZ_DIR/bzzz"
|
|
cp "$SERVICE_FILE" "$SYSTEMD_DIR/bzzz.service"
|
|
chmod 644 "$SYSTEMD_DIR/bzzz.service"
|
|
|
|
systemctl daemon-reload
|
|
systemctl enable bzzz.service
|
|
systemctl start bzzz.service
|
|
|
|
echo "✅ BZZZ service installed and started"
|
|
systemctl status bzzz.service --no-pager -l
|
|
EOF
|
|
|
|
chmod +x "$BUILD_DIR/install-service.sh"
|
|
|
|
log_info "Support files created"
|
|
}
|
|
|
|
# Generate checksums
|
|
generate_checksums() {
|
|
log_step "Generating checksums..."
|
|
|
|
cd "$BUILD_DIR"
|
|
sha256sum * > checksums.txt
|
|
|
|
log_info "Checksums generated"
|
|
}
|
|
|
|
# Show summary
|
|
show_summary() {
|
|
echo ""
|
|
echo -e "${GREEN}🎉 Minimal BZZZ Build Complete!${NC}"
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
echo ""
|
|
echo -e "Build Directory: $BUILD_DIR"
|
|
echo -e "Version: $VERSION"
|
|
echo ""
|
|
echo "Built files:"
|
|
ls -la "$BUILD_DIR"
|
|
echo ""
|
|
echo "Test a binary:"
|
|
echo " $BUILD_DIR/bzzz-linux-amd64 --version"
|
|
echo ""
|
|
}
|
|
|
|
# Main execution
|
|
main() {
|
|
echo -e "${BLUE}🐝 BZZZ Minimal Binary Builder${NC}"
|
|
echo ""
|
|
|
|
build_minimal_bzzz
|
|
copy_support_files
|
|
generate_checksums
|
|
show_summary
|
|
}
|
|
|
|
main "$@" |