Browse Source

Make user creation via environment variables idempotent

Frédéric Guillot 7 years ago
parent
commit
6137b401ee
1 changed files with 6 additions and 0 deletions
  1. 6 0
      cli/create_admin.go

+ 6 - 0
cli/create_admin.go

@@ -8,6 +8,7 @@ import (
 	"fmt"
 	"os"
 
+	"miniflux.app/logger"
 	"miniflux.app/model"
 	"miniflux.app/storage"
 )
@@ -27,6 +28,11 @@ func createAdmin(store *storage.Storage) {
 		os.Exit(1)
 	}
 
+	if store.UserExists(user.Username) {
+		logger.Info(`User %q already exists, skipping creation`, user.Username)
+		return
+	}
+
 	if err := store.CreateUser(user); err != nil {
 		fmt.Println(err)
 		os.Exit(1)