mirror of
https://github.com/navidrome/navidrome.git
synced 2026-12-05 03:07:25 +00:00
Pipeline: Test, Lint, Build / Get version info (push) Canceled after 0s
Pipeline: Test, Lint, Build / Lint Go code (push) Canceled after 0s
Pipeline: Test, Lint, Build / Validate DB migrations (push) Canceled after 0s
Pipeline: Test, Lint, Build / Test Go code (push) Canceled after 0s
Pipeline: Test, Lint, Build / Test Go plugins (push) Canceled after 0s
Pipeline: Test, Lint, Build / Report coverage (push) Canceled after 0s
Pipeline: Test, Lint, Build / Test Go code (Windows) (push) Canceled after 0s
Pipeline: Test, Lint, Build / Test JS code (push) Canceled after 0s
Pipeline: Test, Lint, Build / Lint i18n files (push) Canceled after 0s
Pipeline: Test, Lint, Build / Check Docker configuration (push) Canceled after 0s
Pipeline: Test, Lint, Build / Build (darwin/amd64) (push) Canceled after 0s
Pipeline: Test, Lint, Build / Build (darwin/arm64) (push) Canceled after 0s
Pipeline: Test, Lint, Build / Build (linux/386) (push) Canceled after 0s
Pipeline: Test, Lint, Build / Build (linux/amd64) (push) Canceled after 0s
Pipeline: Test, Lint, Build / Build (linux/arm/v5) (push) Canceled after 0s
Pipeline: Test, Lint, Build / Build (linux/arm/v6) (push) Canceled after 0s
Pipeline: Test, Lint, Build / Build (linux/arm/v7) (push) Canceled after 0s
Pipeline: Test, Lint, Build / Build (linux/arm64) (push) Canceled after 0s
Pipeline: Test, Lint, Build / Build (linux/riscv64) (push) Canceled after 0s
Pipeline: Test, Lint, Build / Build (windows/386) (push) Canceled after 0s
Pipeline: Test, Lint, Build / Build (windows/amd64) (push) Canceled after 0s
Pipeline: Test, Lint, Build / Push to GHCR (push) Canceled after 0s
Pipeline: Test, Lint, Build / Push to Docker Hub () (push) Canceled after 0s
Pipeline: Test, Lint, Build / Cleanup digest artifacts (push) Canceled after 0s
Pipeline: Test, Lint, Build / Build Windows installers (push) Canceled after 0s
Pipeline: Test, Lint, Build / Package/Release (push) Canceled after 0s
Pipeline: Test, Lint, Build / Upload Linux PKG (push) Canceled after 0s
90 lines
2.7 KiB
Go
90 lines
2.7 KiB
Go
package server
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/navidrome/navidrome/conf"
|
|
"github.com/navidrome/navidrome/consts"
|
|
"github.com/navidrome/navidrome/core/ffmpeg"
|
|
"github.com/navidrome/navidrome/db/sqlb"
|
|
"github.com/navidrome/navidrome/log"
|
|
"github.com/navidrome/navidrome/model"
|
|
"github.com/navidrome/navidrome/model/id"
|
|
)
|
|
|
|
// initialSetup keeps reads out of the transaction: SQLite fails a write that follows a read at once,
|
|
// without waiting for the lock
|
|
func initialSetup(ctx context.Context, ds model.DataStore) error {
|
|
if err := ds.Library().StoreMusicFolder(ctx); err != nil {
|
|
return err
|
|
}
|
|
if _, err := ds.Property().Get(ctx, consts.InitialSetupFlagKey); err == nil {
|
|
return nil
|
|
}
|
|
return ds.WithTxRetry(ctx, func(ctx context.Context, tx model.DataStore) error {
|
|
log.Info("Running initial setup")
|
|
if conf.Server().DevAutoCreateAdminPassword != "" {
|
|
if err := createInitialAdminUser(ctx, tx, conf.Server().DevAutoCreateAdminPassword); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return tx.Property().Put(ctx, consts.InitialSetupFlagKey, time.Now().String())
|
|
}, "initial setup")
|
|
}
|
|
|
|
// createInitialAdminUser creates the Dev Admin user if it is not present
|
|
func createInitialAdminUser(ctx context.Context, ds model.DataStore, initialPassword string) error {
|
|
users := ds.User()
|
|
c, err := users.CountAll(ctx, model.QueryOptions{Filters: sqlb.Eq{"user_name": consts.DevInitialUserName}})
|
|
if err != nil {
|
|
return fmt.Errorf("could not access User table: %w", err)
|
|
}
|
|
if c == 0 {
|
|
newID := id.NewRandom()
|
|
log.Warn("Creating initial admin user. This should only be used for development purposes!!",
|
|
"user", consts.DevInitialUserName, "password", initialPassword, "id", newID)
|
|
initialUser := model.User{
|
|
ID: newID,
|
|
UserName: consts.DevInitialUserName,
|
|
Name: consts.DevInitialName,
|
|
Email: "",
|
|
NewPassword: initialPassword,
|
|
IsAdmin: true,
|
|
}
|
|
if err := users.Put(ctx, &initialUser); err != nil {
|
|
return fmt.Errorf("could not create initial admin user: %w", err)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func checkFFmpegInstallation() {
|
|
f := ffmpeg.New()
|
|
_, err := f.CmdPath()
|
|
if err != nil {
|
|
log.Warn("Unable to find ffmpeg. Transcoding will fail if used", err)
|
|
return
|
|
}
|
|
if !f.IsProbeAvailable() {
|
|
log.Warn("Unable to find ffprobe. Transcoding decisions will be limited")
|
|
}
|
|
}
|
|
|
|
func checkExternalCredentials() {
|
|
if conf.Server().EnableExternalServices {
|
|
if !conf.Server().LastFM.Enabled {
|
|
log.Info("Last.fm integration is DISABLED")
|
|
} else {
|
|
log.Debug("Last.fm integration is ENABLED")
|
|
}
|
|
|
|
if !conf.Server().ListenBrainz.Enabled {
|
|
log.Info("ListenBrainz integration is DISABLED")
|
|
} else {
|
|
log.Debug("ListenBrainz integration is ENABLED", "ListenBrainz.BaseURL", conf.Server().ListenBrainz.BaseURL)
|
|
}
|
|
}
|
|
}
|