From 62249670b33e3c5459a9dea2bee0a058e64450d8 Mon Sep 17 00:00:00 2001 From: Michael <12646562+mbround18@users.noreply.github.com> Date: Fri, 23 Apr 2021 14:23:22 -0700 Subject: [PATCH] Docs and release upgrades (#335) * Docs and releases * added specific files for package * added readme * moved odin.md to README.md in odin folder * http-server to huginn * ignore files --- .dockerignore | 3 +- .gitignore | 1 + Cargo.lock | 22 ++--- Cargo.toml | 2 +- Dockerfile | 2 +- Dockerfile.odin | 2 +- Makefile.toml | 4 +- README.md | 48 ++++++----- docs/_config.yml | 2 +- docs/bepinex.md | 4 +- docs/index.md | 31 +++++++ .../getting_started_with_mods.md | 0 src/{http-server => huginn}/Cargo.toml | 14 +++- src/huginn/README.md | 84 +++++++++++++++++++ src/{http-server => huginn}/main.rs | 0 src/{http-server => huginn}/routes/metrics.rs | 0 src/{http-server => huginn}/routes/mod.rs | 0 src/{http-server => huginn}/routes/status.rs | 0 src/odin/Cargo.toml | 13 +++ docs/odin.md => src/odin/README.md | 70 +++++++++++++--- src/odin/executable.rs | 2 +- src/scripts/start_valheim.sh | 2 +- 22 files changed, 250 insertions(+), 56 deletions(-) create mode 100644 docs/index.md rename docs/{ => tutorials}/getting_started_with_mods.md (100%) rename src/{http-server => huginn}/Cargo.toml (60%) create mode 100644 src/huginn/README.md rename src/{http-server => huginn}/main.rs (100%) rename src/{http-server => huginn}/routes/metrics.rs (100%) rename src/{http-server => huginn}/routes/mod.rs (100%) rename src/{http-server => huginn}/routes/status.rs (100%) rename docs/odin.md => src/odin/README.md (56%) diff --git a/.dockerignore b/.dockerignore index a9c61fbb..27d6f5a1 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,6 +4,5 @@ target/ tmp/ docs/ -.github/ .run - +release/ diff --git a/.gitignore b/.gitignore index 8832e524..4d6b61d1 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ target/ tmp/ *.env* docker-compose.*.yml +release diff --git a/Cargo.lock b/Cargo.lock index 71bb1c2d..6bc2db1f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -522,6 +522,17 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47" +[[package]] +name = "huginn" +version = "0.1.0" +dependencies = [ + "cargo-husky", + "log", + "odin", + "tokio", + "warp", +] + [[package]] name = "hyper" version = "0.14.5" @@ -811,17 +822,6 @@ dependencies = [ "zip", ] -[[package]] -name = "odin-http-server" -version = "0.1.0" -dependencies = [ - "cargo-husky", - "log", - "odin", - "tokio", - "warp", -] - [[package]] name = "once_cell" version = "1.7.2" diff --git a/Cargo.toml b/Cargo.toml index f352dd6a..5f33d9a7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ members = [ "src/odin", - "src/http-server" + "src/huginn" ] [profile.dev] diff --git a/Dockerfile b/Dockerfile index 993a5a2e..04368f97 100644 --- a/Dockerfile +++ b/Dockerfile @@ -57,7 +57,7 @@ ENV PUID=1000 \ COPY ./src/scripts/*.sh /home/steam/scripts/ COPY ./src/scripts/entrypoint.sh /entrypoint.sh COPY --from=runtime /usr/local/bin/odin /usr/local/bin/odin -COPY --from=runtime /usr/local/bin/odin-http-server /usr/local/bin/odin-http-server +COPY --from=runtime /usr/local/bin/huginn /usr/local/bin/huginn COPY ./src/scripts/steam_bashrc.sh /home/steam/.bashrc RUN usermod -u ${PUID} steam \ diff --git a/Dockerfile.odin b/Dockerfile.odin index 08e9771b..543f3b67 100644 --- a/Dockerfile.odin +++ b/Dockerfile.odin @@ -38,6 +38,6 @@ RUN cargo-make make -p production release FROM debian:buster-slim as runtime WORKDIR /data/odin COPY --from=builder /data/odin/target/release/odin /usr/local/bin -COPY --from=builder /data/odin/target/release/odin-http-server /usr/local/bin +COPY --from=builder /data/odin/target/release/huginn /usr/local/bin ENTRYPOINT ["/usr/local/bin/odin"] CMD ["--version"] diff --git a/Makefile.toml b/Makefile.toml index 81bd76ca..9091a367 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -71,12 +71,12 @@ condition = { profiles = ["production"] } command = "cargo" args = ["build", "--release", "--bin", "odin"] -# Run http-server release +# Run huginn release [tasks.release-http-server] workspace = false condition = { profiles = ["production"] } command = "cargo" -args = ["build", "--release", "--bin", "odin-http-server"] +args = ["build", "--release", "--bin", "huginn"] [tasks.release] workspace = false diff --git a/README.md b/README.md index 2713a1e5..df554291 100644 --- a/README.md +++ b/README.md @@ -2,19 +2,26 @@ # [Valheim] - - - + + + - - - +## Running on Linux Server - - - +This repo bundles its tools in a way that you can run them without having to install docker! +If you purely want to run this on a Linux based system, without docker, take a look at the links below <3 -## Docker +- [Installing & Using Odin](./src/odin/README.md) + The tool [Odin] runs the show and does almost all the heavy lifting in this repo. It starts, stops, and manages your Valheim server instance. + +- [Installing & Using Huginn](./src/huginn/README.md) + Looking for a way to view the status of your server? Look no further than [Huginn]! + The [Huginn] project is a http server built on the same source as [Odin] and uses these capabilities to expose a few http endpoints. + +> Using the binaries to run on an Ubuntu Server, you will have to be more involved and configure a few things manually. +> If you want a managed, easy one-two punch to manage your server. Then look at the Docker section <3 + +## Running with Docker > [If you are looking for a guide on how to get started click here](https://github.com/mbround18/valheim-docker/discussions/28) > @@ -50,6 +57,7 @@ | WEBHOOK_URL | `` | FALSE | Supply this to get information regarding your server's status in a webhook or Discord notification! [Click here to learn how to get a webhook url for Discord](https://help.dashe.io/en/articles/2521940-how-to-create-a-discord-webhook-url) | | UPDATE_ON_STARTUP | `1` | FALSE | Tries to update the server the container is started. | + #### Container Env Variables | Variable | Default | Required | Description | @@ -82,7 +90,7 @@ Auto update job, queries steam and compares it against your internal steam files Auto backup job produces an output of a `*.tar.gz` file which should average around 30mb for a world that has an average of 4 players consistently building on. You should be aware that if you place the server folder in your saves folder your backups could become astronomical in size. This is a common problem that others have observed, to avoid this please follow the guide for how volume mounts should be made in the `docker-compose.yml`. -#### Http Server +#### [Huginn] Http Server | Variable | Default | Required | Description | | --------- | --------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------- | @@ -159,7 +167,7 @@ services: This repo has a CLI tool called [Odin] in it! It is used for managing the server inside the container. If you are looking for instructions for it click here: [Odin] -[Click here to see advanced environment variables for Odin](./docs/odin.md) +[Click here to see advanced environment variables for Odin](src/odin/README.md) ### [BepInEx Support](./docs/bepinex.md) @@ -183,19 +191,14 @@ This is a tutorial of a recommended path to transfering files. This can be done ## Sponsors - - - - - +AtroposOrbis +arevak ## Release Notifications If you would like to have release notifications tied into your Discord server, click here: - - - +Discord Banner **Note**: The discord is PURELY for release notifications and any + all permissions involving sending chat messages has been disabled. [Any support for this repository must take place on the Discussions.](https://github.com/mbround18/valheim-docker/discussions) @@ -230,7 +233,7 @@ If you would like to have release notifications tied into your Discord server, c - Has a bug where the script has two entries for the world argument. - 1.0.0 (Stable): - It works! It will start your server and stop when you shut down. - - This supports passing in environment variables or arguments to `odin` + - These supports passing in environment variables or arguments to `odin` - Has a bug in which it does not read passed in variables appropriately to Odin. Env variables are not impacted see [#3]. [//]: <> (Github Issues below...........) @@ -251,7 +254,8 @@ If you would like to have release notifications tied into your Discord server, c [#3]: https://github.com/mbround18/valheim-docker/issues/3 [//]: <> (Links below...................) -[Odin]: ./docs/odin.md +[Odin]: src/odin/README.md +[Huginn]: src/huginn/README.md [Valheim]: https://www.valheimgame.com/ [Getting started with mods]: ./docs/getting*started_with_mods.md [If you need help figuring out a cron schedule click here]: https://crontab.guru/#0_1*\_\_\_\_\* diff --git a/docs/_config.yml b/docs/_config.yml index 18854876..8bbf7943 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -1 +1 @@ -theme: jekyll-theme-midnight \ No newline at end of file +theme: jekyll-theme-hacker diff --git a/docs/bepinex.md b/docs/bepinex.md index 4cb7d3ef..45e17b05 100644 --- a/docs/bepinex.md +++ b/docs/bepinex.md @@ -1,5 +1,7 @@ # BepInEx Support +> [As of March 2021, this repo now has an env flag to run with BepInEx or ValheimPlus Click Here to find out more](tutorials/getting_started_with_mods.md) + ## Installing BepInEx > Due to the fact that there are so many variants of installing and running BepInEx; we will be covering only the basics. @@ -57,4 +59,4 @@ | DYLD_LIBRARY_PATH | `"/home/steam/valheim/doorstop_libs"` | TRUE | Sets the library paths. NOTE: This variable is weird and MUST have quotes around it! | | DYLD_INSERT_LIBRARIES | `/home/steam/valheim/doorstop_libs/libdoorstop_x64.so` | TRUE | Sets which library to load. | -[odin]: ./odin.md +[odin]: ../src/odin/README.md diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 00000000..db00c325 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,31 @@ +# Valheim Docker + +## About + +Welcome! Valheim Docker powered by Odin. +The Valheim dedicated game server manager which is designed with resiliency in mind by providing automatic updates, +world backup support, and a user-friendly cli interface. + +## Links + +- [Getting Started](../README.md) + + The repositories Readme contains all relevant information for running with Docker + +- [Discussion for Help and Info](https://github.com/mbround18/valheim-docker/discussions) + + Discussions are what we use for support as they are easily searchable. + +- [Getting Started With & Using Odin](../src/odin/README.md) + + You can run your Valheim server without docker! Take a look at Odin's docs. + +- [Getting Started With & Using Huginn](../src/huginn/README.md) + + Want to see the status of your server? Take a look at Huginn! It can run independently of Odin and this repo. + +## Tutorials + +- [Getting Started With Mods](tutorials/getting_started_with_mods.md) +- [How to transfer files](tutorials/how-to-transfer-files.md) + diff --git a/docs/getting_started_with_mods.md b/docs/tutorials/getting_started_with_mods.md similarity index 100% rename from docs/getting_started_with_mods.md rename to docs/tutorials/getting_started_with_mods.md diff --git a/src/http-server/Cargo.toml b/src/huginn/Cargo.toml similarity index 60% rename from src/http-server/Cargo.toml rename to src/huginn/Cargo.toml index 4a2e451e..ea5563bc 100644 --- a/src/http-server/Cargo.toml +++ b/src/huginn/Cargo.toml @@ -1,11 +1,21 @@ [package] -name = "odin-http-server" +name = "huginn" version = "0.1.0" authors = ["mbround18"] edition = "2018" +license = "BSD-3-Clause License" +description = "Valheim http status" +readme = "README.md" +homepage = "https://github.com/mbround18/valheim-docker" +repository = "https://github.com/mbround18/valheim-docker" +include = [ + "**/*.rs", + "**/*.yaml", + "Cargo.toml", +] [[bin]] -name = "odin-http-server" +name = "huginn" path = "main.rs" [dependencies] diff --git a/src/huginn/README.md b/src/huginn/README.md new file mode 100644 index 00000000..3d5bf93e --- /dev/null +++ b/src/huginn/README.md @@ -0,0 +1,84 @@ +# Huginn + +Huginn is a status server used to check the status of your Valheim server. + +> [Who is Huginn?](https://en.wikipedia.org/wiki/Huginn_and_Muninn) + +## Setup + +1. Install Rust & git +2. Clone the repo +3. `cargo install cargo-make` +4. `makers -e production release` +5. `chmod +x ./target/debug/huginn` +6. Copy `./target/debug/huginn` to `/usr/local/bin` + +## Usage + +### Environment Variables + +| Variable | Default | Required | Description | +| --------- | --------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------- | +| ADDRESS | `Your Public IP` | FALSE | This setting is used in conjunction with `odin status` and setting this will stop `odin` from trying to fetch your public IP | +| HTTP_PORT | `anything above 1024` | FALSE | Setting this will spin up a little http server that provides two endpoints for you to call. | + + +### Manually Launching + +Simply launch `huginn` in the background with: + +```shell +cd /path/to/your/valheim/server/folder +huginn & +``` + +### Systemd service + +1. With the root user or using sudo run + + ```shell + nano /etc/systemd/system/huginn.service + ``` + +2. Copy and paste the text below + + ```toml + [Unit] + Description=Huginn Valheim Status Server + After=network.target + StartLimitIntervalSec=0 + + [Service] + Type=simple + Restart=always + RestartSec=1 + User=steam + Environment="HTTP_PORT=3000" "ADDRESS=127.0.0.1:2457" + WorkingDirectory=/home/steam/valheim + ExecStart=/usr/bin/env /usr/local/bin/huginn + + [Install] + WantedBy=multi-user.target + ``` + +3. Make any necessary changes to the service to fit your needs. + (Remember, the port you use in your `ADDRESS` must be your query port which is +1 of your game port.) + +4. Next save the file and start the service. + + ```shell + sudo systemctl start huginn + ``` + +5. To have the server start on server launch, run: + + ```shell + sudo systemctl enable huginn + ``` + +## Endpoints + +| Endpoint | Description | +|------------|------------| +| `/metrics` | Provides a Prometheus compatible output of the server status. [Click here to see a guide on how to get a dashboard setup.](https://github.com/mbround18/valheim-docker/discussions/330) | +| `/status` | Provides a more traditional JSON output of the server status. | diff --git a/src/http-server/main.rs b/src/huginn/main.rs similarity index 100% rename from src/http-server/main.rs rename to src/huginn/main.rs diff --git a/src/http-server/routes/metrics.rs b/src/huginn/routes/metrics.rs similarity index 100% rename from src/http-server/routes/metrics.rs rename to src/huginn/routes/metrics.rs diff --git a/src/http-server/routes/mod.rs b/src/huginn/routes/mod.rs similarity index 100% rename from src/http-server/routes/mod.rs rename to src/huginn/routes/mod.rs diff --git a/src/http-server/routes/status.rs b/src/huginn/routes/status.rs similarity index 100% rename from src/http-server/routes/status.rs rename to src/huginn/routes/status.rs diff --git a/src/odin/Cargo.toml b/src/odin/Cargo.toml index 697227bf..2efc5d6a 100644 --- a/src/odin/Cargo.toml +++ b/src/odin/Cargo.toml @@ -3,6 +3,19 @@ name = "odin" version = "1.4.0" authors = ["mbround18"] edition = "2018" +license = "BSD-3-Clause License" +description = "Valheim server manager" +readme = "README.md" +homepage = "https://github.com/mbround18/valheim-docker" +repository = "https://github.com/mbround18/valheim-docker" +keywords = ["cli", "valheim", "gameserver"] +categories = ["command-line-utilities"] +include = [ + "**/*.rs", + "**/*.yaml", + "Cargo.toml", +] + [[bin]] name = "odin" diff --git a/docs/odin.md b/src/odin/README.md similarity index 56% rename from docs/odin.md rename to src/odin/README.md index 35fbf06b..ab3b167d 100644 --- a/docs/odin.md +++ b/src/odin/README.md @@ -2,6 +2,8 @@ Odin is a CLI tool utilized for installing, starting, and stopping [Valheim] servers +> [Who is odin?](https://en.wikipedia.org/wiki/Odin) + ## Odin Specific Environment Variables > These are set automatically by Odin; @@ -20,17 +22,20 @@ Odin is a CLI tool utilized for installing, starting, and stopping [Valheim] ser - If you have the proper build tools installed you should be able to run Odin on any system. - Current Supported Architecture: Unix & Linux based systems. -## Installation +## Setup > Make sure you have build essentials installed before you install this crate -```sh -cargo install --git https://github.com/mbround18/valheim-docker.git --branch main -``` +1. Install Rust & git +2. Clone the repo +3. `cargo install cargo-make` +4. `makers -e production release` +5. `chmod +x ./target/debug/odin` +6. Copy `./target/debug/odin` to `/usr/local/bin` ## Usage -![Main Menu](./assets/main-menu.png) +![Main Menu](../../docs/assets/main-menu.png) ### Install Valheim @@ -38,7 +43,7 @@ cargo install --git https://github.com/mbround18/valheim-docker.git --branch mai odin install ``` -![Install Menu](./assets/install-menu.png) +![Install Menu](../../docs/assets/install-menu.png) ### Start Valheim @@ -46,7 +51,7 @@ odin install odin start ``` -![Start Menu](./assets/start-menu.png) +![Start Menu](../../docs/assets/start-menu.png) ### Stop Valheim @@ -54,14 +59,14 @@ odin start odin stop ``` -![Install Menu](./assets/stop-menu.png) +![Install Menu](../../docs/assets/stop-menu.png) ### Status #### Local Server ```sh -odin http-server +odin status ``` #### Remote Server @@ -69,5 +74,50 @@ odin http-server Replace the `xx.xx.xx.xx` with your server IP and `query-port` with the `PORT` variable +1 (ex: if `2456` use `2457` which is the steam query port.) ```shell -odin http-server --address "xx.xx.xx.xx:query-port" +odin status --address "xx.xx.xx.xx:query-port" ``` + + +## Systemd service + +1. With the root user or using sudo run + + ```shell + nano /etc/systemd/system/valheim.service + ``` + +2. Copy and paste the text below + + ```toml + [Unit] + Description=Valheim Server + After=network.target + StartLimitIntervalSec=0 + + [Service] + Type=simple + Restart=always + RestartSec=1 + User=steam + Environment="PORT=2456" 'NAME="Valheim Docker"' "WORLD=Dedicated" "PUBLIC=1" "PASSWORD=changeme" + WorkingDirectory=/home/steam/valheim + ExecStartPre=/usr/bin/env /usr/local/bin/odin configure + ExecStart=/usr/bin/env /usr/local/bin/odin start + ExecStop=/usr/bin/env /usr/local/bin/odin stop + + [Install] + WantedBy=multi-user.target + ``` + +3. Make any necessary changes to the service to fit your needs. +4. Next save the file and start the service. + + ```shell + sudo systemctl start valheim + ``` + +5. To have the server start on server launch, run: + + ```shell + sudo systemctl enable valheim + ``` diff --git a/src/odin/executable.rs b/src/odin/executable.rs index 3374f75c..d1345da8 100644 --- a/src/odin/executable.rs +++ b/src/odin/executable.rs @@ -45,7 +45,7 @@ pub fn handle_exit_status(result: std::io::Result, success_message: info!("{}", success_message); } else { match exit_status.code() { - Some(code) => info!("Exited with http-server code: {}", code), + Some(code) => info!("Exited with http code: {}", code), None => info!("Process terminated by signal"), } } diff --git a/src/scripts/start_valheim.sh b/src/scripts/start_valheim.sh index 4e7dbaed..71d2747d 100644 --- a/src/scripts/start_valheim.sh +++ b/src/scripts/start_valheim.sh @@ -123,7 +123,7 @@ if [ ! "${TYPE}" = "vanilla" ]; then fi if [ -n "${HTTP_PORT}" ]; then - odin-http-server & + huginn & export ODIN_HTTP_SERVER_PID=$! fi