From b1ea9e72ad56ac503e224d547fa7e779f885b389 Mon Sep 17 00:00:00 2001 From: Fimeg Date: Wed, 29 Oct 2025 13:08:52 -0400 Subject: [PATCH] Add welcome mode for server configuration --- aggregator-server/cmd/server/main.go | 85 +++++++++++++++++++++++++++- docker-compose.yml | 3 +- 2 files changed, 85 insertions(+), 3 deletions(-) diff --git a/aggregator-server/cmd/server/main.go b/aggregator-server/cmd/server/main.go index db970f1..aa11919 100644 --- a/aggregator-server/cmd/server/main.go +++ b/aggregator-server/cmd/server/main.go @@ -16,6 +16,83 @@ import ( "github.com/gin-gonic/gin" ) +func startWelcomeModeServer() { + router := gin.Default() + + // Add CORS middleware + router.Use(middleware.CORSMiddleware()) + + // Health check + router.GET("/health", func(c *gin.Context) { + c.JSON(200, gin.H{"status": "waiting for configuration"}) + }) + + // Welcome page with setup instructions + router.GET("/", func(c *gin.Context) { + html := ` + + + + RedFlag - Setup Required + + + +
+

🚀 RedFlag Server

+
+

⏳ Server is waiting for configuration

+

Choose one of the setup methods below:

+
+ +
+
+

Option 1: Command Line Setup

+

Run this command in your terminal:

+
docker-compose exec server ./redflag-server --setup
+

Follow the interactive prompts to configure your server.

+
+ +
+

Option 2: Web Setup (Coming Soon)

+

Web-based configuration wizard will be available in a future release.

+

For now, use the command line setup above.

+
+
+ +
+

After configuration, the server will automatically restart.

+

Refresh this page to see the admin interface.

+
+
+ +` + c.Data(200, "text/html; charset=utf-8", []byte(html)) + }) + + // Setup endpoint for web configuration (future) + router.GET("/setup", func(c *gin.Context) { + c.JSON(200, gin.H{ + "message": "Web setup coming soon", + "instructions": "Use: docker-compose exec server ./redflag-server --setup", + }) + }) + + log.Printf("Welcome mode server started on :8080") + log.Printf("Waiting for configuration...") + + if err := router.Run(":8080"); err != nil { + log.Fatal("Failed to start welcome mode server:", err) + } +} + func main() { // Parse command line flags var setup bool @@ -43,7 +120,13 @@ func main() { // Load configuration cfg, err := config.Load() if err != nil { - log.Fatal("Failed to load configuration:", err) + log.Printf("Server waiting for configuration: %v", err) + log.Printf("Run: docker-compose exec server ./redflag-server --setup") + log.Printf("Or configure via web interface at: http://localhost:8080/setup") + + // Start welcome mode server + startWelcomeModeServer() + return } // Set JWT secret diff --git a/docker-compose.yml b/docker-compose.yml index 99bbb4f..ebb78ca 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -24,7 +24,6 @@ services: container_name: redflag-server volumes: - ./aggregator-agent/redflag-agent:/app/redflag-agent:ro - - ./aggregator-server/.env:/app/.env - server-data:/app/data depends_on: postgres: @@ -39,7 +38,7 @@ services: - REDFLAG_DB_PASSWORD=redflag - REDFLAG_SERVER_HOST=0.0.0.0 - REDFLAG_SERVER_PORT=8080 - command: ["sh", "-c", "if [ ! -f /app/.env ]; then ./redflag-server --setup; fi && ./redflag-server --migrate && ./redflag-server"] + command: ["./redflag-server"] restart: unless-stopped volumes: