sindri

package module
v1.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 16, 2024 License: MIT Imports: 32 Imported by: 0

README

sindri godoc goreportcard license

Easily run a dedicated Valheim server with mods from thunderstore.io and a way to easily share those mods with Valheim clients.

usage

Usage:
  sindri [flags]

Flags:
      --addr string              address for sindri (default ":8080")
      --admin int64Slice         Valheim server admin Steam IDs (default [])
      --backup-long duration     Valheim server -backuplong duration
      --backup-short duration    Valheim server -backupshort duration
      --backups int              Valheim server -backup amount
      --ban int64Slice           Valheim server banned Steam IDs (default [])
      --beta string              Steam beta branch
      --beta-password string     Steam beta password
      --combat-modifier          Valheim server -modifier combat
      --crossplay                Valheim server enable -crossplay
      --death-penalty-modifier   Valheim server -modifier deathpenalty
  -h, --help                     help for sindri
      --instance-id string       Valheim server -instanceid
  -m, --mod stringArray          Thunderstore mods (case-sensitive)
      --mods-only                do not redownload Valheim
      --name string              Valheim server -name (default "sindri")
      --no-build-cost            Valheim server -setkey nobuildcost
	  --no-db                    do not expose the world .db file for download
      --no-download              do not redownload Valheim or mods
	  --no-fwl                   do not expose the world .fwl file information
      --no-map                   Valheim server -setkey nomap
      --passive-mobs             Valheim server -setkey passivemobs
      --permit int64Slice        Valheim server permitted Steam IDs (default [])
      --player-events            Valheim server -setkey playerevents
      --port int                 Valheim server -port (0 to use default)
      --portal-modifier          Valheim server -modifier portals
      --preset                   Valheim server -preset
      --public                   Valheim server make -public
      --raid-modifier            Valheim server -modifier raids
      --resource-modifier        Valheim server -modifier resources
      --rm stringArray           Thunderstore mods to remove (case-sensitive)
  -r, --root string              root directory for sindri (-savedir resides here) (default "~/.local/share/sindri")
      --save-interval duration   Valheim server -saveinterval duration
  -s, --state string             state directory for sindri (default "~/.local/share/sindri")
  -V, --verbose count            verbosity for sindri
  -v, --version                  version for sindri
      --world string             Valheim server -world (default "sindri")
Root directory

Sindri is tied to its root directory, meaning that if you stop Sindri and then start it back up with the same root directory, it will pick back up where it left off: same mod list, same world, etc.

By default, the root directory will be $XDG_DATA_HOME/sindri per the XDG Base Directory Specification. This can be overridden with --root.

docker run \
    # Make sure to map a volume to the --root directory
    # or important data such as your world saves will be
    # tied to the container's filesystem, making it easy
    # to lose if the container is destroyed.
    --volume $(pwd)/sindri:/var/lib/sindri \
    # Valheim listens on port 2456 for UDP traffic by default.
    --publish 2456:2456/udp \
    ghcr.io/frantjc/sindri:1.3.2 \
        --root /var/lib/sindri
Mods

Sindri downloads its mods from thunderstore.io. Mods can be referenced a number of ways. For example, EquipmentAndQuickSlots can be referenced by its full name, RandyKnapp-EquipmentAndQuickSlots-0.2.0 (note that the version is optional--if omitted, the latest version is used); by a distribution-spec-like reference, RandyKnapp/EquipmentAndQuickSlots:0.2.0; or by a GitHub-Actions-like reference, RandyKnapp/EquipmentAndQuickSlots@0.2.0. Note that these are all case-sensitive.

The desired list of mods can be passed to Sindri via --mod.

docker run \
    --volume $(pwd)/sindri:/var/lib/sindri \
    --publish 2456:2456/udp \
    ghcr.io/frantjc/sindri:1.3.2 \
        --root /var/lib/sindri \
        --mod RandyKnapp/EquipmentAndQuickSlots
Distributing mods to clients

After Sindri is running, if it has any mods, you can download them from it (the exact versions!) for your Valheim client. It listens on :8080 by default which can be overridden with --addr.

docker run \
    --volume $(pwd)/sindri:/var/lib/sindri \
    --publish 2456:2456/udp \
    --publish 8080:8080 \
    ghcr.io/frantjc/sindri:1.3.2 \
        --root /var/lib/sindri

Then you can use your HTTP client of choice to download a .tar with the mods.

cd "C:\Program Files (x86)\Steam\steamapps\common\Valheim"
curl -fSs http://your-sindri-address/mods.gz | tar -xzf -

After the initial install, Sindri supplies some helpful scripts to use to update and uninstall it, respectively.

cd "C:\Program Files (x86)\Steam\steamapps\common\Valheim"
update-sindri
cd "C:\Program Files (x86)\Steam\steamapps\common\Valheim"
uninstall-sindri
Valheim options

Valheim arguments other than -savedir (sourced from --root) and -password (required and sourced from the environment variable VALHEIM_PASSWORD) can be passed through Sindri by flags of the same name. If not provided, --world and --name default to "sindri", while --port will not be passed to Valheim if not provided. Lastly, --public only needs to be defined, it does not need the value of "1".

docker run \
    --volume $(pwd)/sindri:/var/lib/sindri \
    # Make sure to publish the correct port if you change it.
    --publish 3567:3567/udp \
    --publish 8080:8080 \
    --env VALHEIM_PASSWORD=atleast5chars \
    ghcr.io/frantjc/sindri:1.3.2 \
        --root /var/lib/sindri \
        --mod RandyKnapp/EquipmentAndQuickSlots \
        --port 3567 \
        --world "My world" \
        --name "My world" \
        --public
Beta versions

Sindri can run a beta version of Valheim by using --beta and --beta-password.

docker run \
    --volume $(pwd)/sindri:/var/lib/sindri \
    --publish 3567:3567/udp \
    --publish 8080:8080 \
    --env VALHEIM_PASSWORD=atleast5chars \
    ghcr.io/frantjc/sindri:1.3.2 \
        --root /var/lib/sindri \
        --beta public-test \
        --beta-password yesimadebackups
Make it faster

Sindri can be made to start up faster on subsequent runs by skipping redownloading Valheim and/or mods by using --no-download and/or --mods-only.

docker run \
    --volume $(pwd)/sindri:/var/lib/sindri \
    --publish 3567:3567/udp \
    --publish 8080:8080 \
    --env VALHEIM_PASSWORD=atleast5chars \
    ghcr.io/frantjc/sindri:1.3.2 \
        --root /var/lib/sindri \
        --no-download

Documentation

Index

Constants

View Source
const (
	// ImageRef is the image reference that Sindri
	// stores a game and its mods' files at inside
	// of it's .tar file.
	ImageRef = "frantj.cc/sindri"
	// MetadataLayerDigestLabel is the image config file label
	// that Sindri stores Metadata at.
	MetadataLayerDigestLabel = "cc.frantj.sindri.metadata-layer-digest"
)

Variables

View Source
var VersionCore = "1.3.2"

VersionCore is the SemVer version core of sindri. Meant to be be overridden at build time, but kept up-to-date sometimes to best support `go install`.

Functions

func LogExec

func LogExec(log Logger, cmd *exec.Cmd)

LogExec redirects a command's stdout and stderr to the given Logger.

func SemVer added in v1.2.7

func SemVer() string

SemVer returns the semantic version of forge as built from VersionCore and debug build info.

func WithLogger

func WithLogger(ctx context.Context, log Logger) context.Context

WithLogger returns a Context from the parent Context with the given Logger inside of it.

Types

type Logger

type Logger = logr.Logger

Logger is an alias to logr.Logger in case the logging library is desired to be swapped out.

func LoggerFrom

func LoggerFrom(ctx context.Context) Logger

LoggerFrom returns a Logger embedded within the given Context or a no-op Logger if no such Logger exists.

func NewLogger

func NewLogger() Logger

NewLogger creates a new Logger.

type Metadata

type Metadata struct {
	SteamAppLayerDigest string                 `json:"steamAppLayerDigest,omitempty"`
	Mods                map[string]ModMetadata `json:"mods,omitempty"`
}

Metadata stores metadata about a downloaded game and added mods.

type ModMetadata

type ModMetadata struct {
	LayerDigest string `json:"layerDigest,omitempty"`
	Version     string `json:"version,omitempty"`
}

ModMetadata stores metadata about an added mod.

type Opt

type Opt func(*Sindri)

Opt is an option to pass when creating a new Sindri instance.

func WithBeta added in v0.6.3

func WithBeta(beta string, password string) Opt

WithBeta makes Sindri use the given Steam beta.

func WithRootDir

func WithRootDir(dir string) Opt

WithRootDir sets a *Sindri's root directory where it will store any persistent data.

func WithStateDir

func WithStateDir(dir string) Opt

WithStateDir sets a *Sindri's state directory where it will store any ephemeral data.

type Sindri

type Sindri struct {
	SteamAppID         string
	BepInEx            *thunderstore.Package
	ThunderstoreClient *thunderstore.Client
	// contains filtered or unexported fields
}

Sindri manages the files of a game and its mods.

func New

func New(steamAppID string, bepInEx *thunderstore.Package, thunderstoreClient *thunderstore.Client, opts ...Opt) (*Sindri, error)

New creates a new Sindri instance with the given required arguments and options. Sindri can also be safely created directly so long as the exported fields are set to non-nil values.

func (*Sindri) AddMods added in v0.6.4

func (s *Sindri) AddMods(ctx context.Context, mods ...string) error

AddMods installs or updates the given mods and their dependencies using thunderstore.io.

func (*Sindri) AppUpdate

func (s *Sindri) AppUpdate(ctx context.Context) error

AppUpdate uses `steamcmd` to installed or update the game that *Sindri is managing.

func (*Sindri) Extract

func (s *Sindri) Extract(mods ...string) (io.ReadCloser, error)

Extract returns an io.ReadCloser of a tarball containing the files of the game and the given mods.

func (*Sindri) ExtractMods

func (s *Sindri) ExtractMods(mods ...string) (io.ReadCloser, error)

ExtractMods returns an io.ReadCloser containing a tarball containing the files just the game's mods.

func (*Sindri) Mods added in v0.7.0

func (s *Sindri) Mods() ([]thunderstore.Package, error)

Mods returns the installed thunderstore.io packages.

func (*Sindri) RemoveMods added in v0.7.0

func (s *Sindri) RemoveMods(_ context.Context, mods ...string) error

RemoveMods removes the given mods.

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL