mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-19 17:03:54 +00:00
Some checks are pending
Pipeline: Test, Lint, Build / Lint Go code (push) Waiting to run
Pipeline: Test, Lint, Build / Package/Release (push) Blocked by required conditions
Pipeline: Test, Lint, Build / Upload Linux PKG (push) Blocked by required conditions
Pipeline: Test, Lint, Build / Get version info (push) Waiting to run
Pipeline: Test, Lint, Build / Validate DB migrations (push) Waiting to run
Pipeline: Test, Lint, Build / Test Go code (push) Waiting to run
Pipeline: Test, Lint, Build / Test Go plugins (push) Waiting to run
Pipeline: Test, Lint, Build / Report coverage (push) Blocked by required conditions
Pipeline: Test, Lint, Build / Test Go code (Windows) (push) Waiting to run
Pipeline: Test, Lint, Build / Test JS code (push) Waiting to run
Pipeline: Test, Lint, Build / Build-9 (push) Blocked by required conditions
Pipeline: Test, Lint, Build / Build-10 (push) Blocked by required conditions
Pipeline: Test, Lint, Build / Push to GHCR (push) Blocked by required conditions
Pipeline: Test, Lint, Build / Lint i18n files (push) Waiting to run
Pipeline: Test, Lint, Build / Check Docker configuration (push) Waiting to run
Pipeline: Test, Lint, Build / Build (push) Blocked by required conditions
Pipeline: Test, Lint, Build / Build-1 (push) Blocked by required conditions
Pipeline: Test, Lint, Build / Build-2 (push) Blocked by required conditions
Pipeline: Test, Lint, Build / Build-3 (push) Blocked by required conditions
Pipeline: Test, Lint, Build / Build-4 (push) Blocked by required conditions
Pipeline: Test, Lint, Build / Build-5 (push) Blocked by required conditions
Pipeline: Test, Lint, Build / Build-6 (push) Blocked by required conditions
Pipeline: Test, Lint, Build / Build-7 (push) Blocked by required conditions
Pipeline: Test, Lint, Build / Build-8 (push) Blocked by required conditions
Pipeline: Test, Lint, Build / Push to Docker Hub (push) Blocked by required conditions
Pipeline: Test, Lint, Build / Cleanup digest artifacts (push) Blocked by required conditions
Pipeline: Test, Lint, Build / Build Windows installers (push) Blocked by required conditions
* refactor(scanner): remove the legacy ffmpeg metadata extractor The ffmpeg extractor in scanner/metadata_old has not been wired into the scanner since the taglib-only rewrite, so it was only exercised by its own tests. Remove the package, the FFmpeg.Probe method and its ffmetadata command that only it used, and the startup fallback for Scanner.Extractor="ffmpeg". Configs that still set it keep working: unknown extractors already fall back to taglib with a warning. * fix(conf): warn and fall back to taglib for an unknown Scanner.Extractor Validate the option when loading the config, so invalid values such as the removed "ffmpeg" extractor are reported once at startup instead of only when a library storage is created.
96 lines
2.7 KiB
Go
96 lines
2.7 KiB
Go
package server
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/Masterminds/squirrel"
|
|
"github.com/navidrome/navidrome/conf"
|
|
"github.com/navidrome/navidrome/consts"
|
|
"github.com/navidrome/navidrome/core/ffmpeg"
|
|
"github.com/navidrome/navidrome/log"
|
|
"github.com/navidrome/navidrome/model"
|
|
"github.com/navidrome/navidrome/model/id"
|
|
)
|
|
|
|
func initialSetup(ds model.DataStore) {
|
|
ctx := context.TODO()
|
|
err := ds.WithTx(func(tx model.DataStore) error {
|
|
if err := tx.Library().StoreMusicFolder(ctx); err != nil {
|
|
return err
|
|
}
|
|
|
|
properties := tx.Property()
|
|
_, err := properties.Get(ctx, consts.InitialSetupFlagKey)
|
|
if err == nil {
|
|
return nil
|
|
}
|
|
log.Info("Running initial setup")
|
|
if conf.Server.DevAutoCreateAdminPassword != "" {
|
|
if err = createInitialAdminUser(ctx, tx, conf.Server.DevAutoCreateAdminPassword); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
err = properties.Put(ctx, consts.InitialSetupFlagKey, time.Now().String())
|
|
return err
|
|
}, "initial setup")
|
|
if err != nil {
|
|
log.Fatal("Error running initial setup", err)
|
|
}
|
|
}
|
|
|
|
// If the Dev Admin user is not present, create it
|
|
func createInitialAdminUser(ctx context.Context, ds model.DataStore, initialPassword string) error {
|
|
users := ds.User()
|
|
c, err := users.CountAll(ctx, model.QueryOptions{Filters: squirrel.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)
|
|
}
|
|
}
|
|
}
|