Skip to content

Commit

Permalink
Mbround18 #8 auto update (#9)
Browse files Browse the repository at this point in the history
* Auto Update Functions and clean up

* Fixed redundant start captures and fixed arguments

* Fixed output messages
  • Loading branch information
mbround18 authored Feb 7, 2021
1 parent 82e8515 commit c219a6b
Show file tree
Hide file tree
Showing 17 changed files with 456 additions and 118 deletions.
159 changes: 159 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ which = "4.0.2"
dialoguer = "0.7.1"
tinytemplate = "1.1"
serde = { version = "1.0", features = ["derive"] }
sysinfo = "0.16.1"

[profile.dev]
opt-level = 0
Expand Down
36 changes: 29 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ RUN cargo install --path . \
FROM registry.hub.docker.com/library/alpine:latest as ScriptSanitize

WORKDIR /data/scripts
COPY ./scripts/* .
COPY src/scripts/* ./

RUN apk add dos2unix --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted \
&& dos2unix /data/scripts/**
Expand All @@ -27,20 +27,42 @@ RUN apk add dos2unix --update-cache --repository http://dl-3.alpinelinux.org/al
# --------------- #
FROM registry.hub.docker.com/cm2network/steamcmd:root

RUN apt-get update \
&& apt-get install -y htop net-tools nano netcat curl wget
RUN apt-get update \
&& apt-get install -y \
htop net-tools nano \
netcat curl wget \
cron

USER steam
# Set up timezone information
ENV TZ=America/Los_Angeles
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN mkdir -p /home/steam/valheim \
&& mkdir -p /home/steam/scripts
# Copy hello-cron file to the cron.d directory
COPY --chown=steam:steam src/cron/auto-update /etc/cron.d/auto-update

# Give execution rights on the cron job
RUN chmod 0644 /etc/cron.d/auto-update

# Apply cron job
RUN crontab /etc/cron.d/auto-update

# Setup Directories
RUN usermod -d /home/steam steam \
&& mkdir -p /home/steam/valheim \
&& chown -R steam:steam /home/steam/valheim \
&& mkdir -p /home/steam/scripts \
&& chown -R steam:steam /home/steam/scripts

# Switch to steam user.
USER steam

ENV NAME "Valheim Docker"
ENV WORLD "Dedicated"
ENV PORT "2456"
ENV PASSWORD ""
ENV AUTO_UPDATE "0"

COPY --from=ScriptSanitize --chown=steam:steam /data/scripts/entrypoint.sh /home/steam/scripts/
COPY --from=ScriptSanitize --chown=steam:steam /data/scripts/*.sh /home/steam/scripts/
COPY --from=RustBuilder --chown=steam:steam /data/odin/target/release /home/steam/odin

RUN mkdir -p /home/steam/valheim \
Expand Down
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
version: "3"
services:
valheim:
image: mbround18/valheim:latest
Expand All @@ -13,5 +14,5 @@ services:
- "2457:2457/udp"
- "2458:2458/udp"
volumes:
- ./tmp/valheim/saves:/home/steam/.config/unity3d/IronGate/Valheim
- ./tmp/valheim/server:/home/steam/valheim
- ./tmp/saves:/home/steam/.config/unity3d/IronGate/Valheim
- ./tmp/server:/home/steam/valheim
14 changes: 7 additions & 7 deletions src/commands/install.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
use crate::steamcmd::steamcmd_command;
use crate::executable::{execute_mut, handle_exit_status};
use std::process::Stdio;
use crate::executable::{execute_mut};
use std::process::{Stdio, ExitStatus};
use crate::utils::{get_working_dir};
use log::{info};

pub fn invoke(app_id: i64) {
println!("Installing {} to {}", app_id, get_working_dir());
pub fn invoke(app_id: i64) -> std::io::Result<ExitStatus> {
info!("Installing {} to {}", app_id, get_working_dir());
let login = "+login anonymous".to_string();
let force_install_dir = format!("+force_install_dir {}", get_working_dir()).to_string();
let app_update = format!("+app_update {}", app_id);
let mut steamcmd = steamcmd_command();
let mut steamcmd = steamcmd_command();
let install_command = steamcmd
.args(&[login, force_install_dir, app_update])
.arg("+quit")
.stdout(Stdio::inherit())
.stderr(Stdio::inherit());
let result = execute_mut(install_command);
handle_exit_status(result, "Successfully installed Valheim!".to_string())
execute_mut(install_command)
}
Loading

0 comments on commit c219a6b

Please sign in to comment.