Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix | Argument Settings arent taking #747

Merged
merged 2 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_TOKEN }}

- name: "JQ: Install"
run: |
sudo apt-get install -y jq

- name: "Cargo Make: Get Latest Version"
id: cargo-make
run: |
echo "version=$(curl -s https://api.github.com/repos/sagiegurari/cargo-make/releases/latest | jq -r '.tag_name')" >> $GITHUB_OUTPUT

- name: Build and push
uses: docker/build-push-action@v5
with:
Expand All @@ -70,3 +79,4 @@ jobs:
"GITHUB_SHA=${GITHUB_SHA}"
"GITHUB_REF=${GITHUB_REF}"
"GITHUB_REPOSITORY=${GITHUB_REPOSITORY}"
"CARGO_MAKE_VERSION=${{ steps.cargo-make.outputs.version }}"
52 changes: 20 additions & 32 deletions Cargo.lock

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

11 changes: 10 additions & 1 deletion Dockerfile.odin
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@ RUN cargo chef cook --release --recipe-path recipe.json
# -- Odin Project Mangement -- #
# ---------------------------- #

FROM mbround18/cargo-make:latest as cargo-make
FROM rust:${RUST_VERSION} as cargo-make

ARG CARGO_MAKE_VERSION=0.37.2

ADD https://github.com/sagiegurari/cargo-make/releases/download/${CARGO_MAKE_VERSION}/cargo-make-v${CARGO_MAKE_VERSION}-x86_64-unknown-linux-gnu.zip /tmp/cargo-make.zip
RUN unzip /tmp/cargo-make.zip -d /tmp \
&& mv /tmp/cargo-make-v${CARGO_MAKE_VERSION}-x86_64-unknown-linux-gnu/cargo-make /usr/local/bin/cargo-make \
&& rm -rf /tmp/cargo-make* \
&& chmod +x /usr/local/bin/cargo-make


# ------------------ #
# -- Odin Builder -- #
Expand Down
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,18 @@ wsl.clean-all:

wsl.clippy: wsl.sync
cd $(BUILD_DIR) && cargo clippy

docker.build:
docker compose -f docker-compose.dev.yml build

docker.up:
docker compose -f docker-compose.dev.yml up

docker.build-up:
docker compose -f docker-compose.dev.yml up --build

docker.down:
docker compose -f docker-compose.dev.yml disown

docker.ssh:
docker compose -f docker-compose.dev.yml exec valheim gosu valheim bash
2 changes: 1 addition & 1 deletion src/odin/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ pub fn initialize_logger(debug: bool) -> Result<(), SetLoggerError> {
}

pub fn debug_mode() -> bool {
let debug_mode = env::var("DEBUG_MODE").unwrap_or(String::new());
let debug_mode = env::var("DEBUG_MODE").unwrap_or_default();
parse_truthy(&debug_mode).unwrap_or(false)
}
74 changes: 45 additions & 29 deletions src/odin/server/startup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,61 +55,76 @@ pub fn start(config: ValheimArguments) -> CommandResult {
constants::LD_LIBRARY_PATH_VAR,
format!("{}/linux64", game_directory()).as_str(),
);
info!("Setting up base command");
info!("Launching With Args: \n{:#?}", &config);
debug!("Setting up base command");
debug!("Launching With Args: \n{:#?}", &config);
// Sets the base command for the server
let mut base_command = command
let base_command = command
.env("SteamAppId", fetch_var("APPID", "892970"))
.current_dir(game_directory());

// Sets the name of the server, (Can be set with ENV variable NAME)
let name = format!("-name {}", fetch_var("NAME", config.name.as_str()));
base_command.arg(name);
let name = fetch_var("NAME", &config.name);
debug!("Setting name to: {}", &name);
base_command.arg("-name");
base_command.arg(&name);

// Sets the port of the server, (Can be set with ENV variable PORT)
let port = format!("-port {}", fetch_var("PORT", config.port.as_str()));
base_command.arg(port);
let port = fetch_var("PORT", &config.port);
debug!("Setting port to: {}", &port);
base_command.args(["-port", &port]);

// Sets the world of the server, (Can be set with ENV variable WORLD)
let world = format!("-world {}", fetch_var("WORLD", config.world.as_str()));
base_command.arg(world);
let world = fetch_var("WORLD", &config.world);
debug!("Setting world to: {}", &fetch_var("WORLD", &world));
base_command.arg("-world");
base_command.arg(&world);

// Determines if the server is public or not
let public = format!("-public {}", fetch_var("PUBLIC", config.public.as_str()));
base_command.arg(public);
let public = fetch_var("PUBLIC", config.public.as_str());
debug!("Setting public to: {}", &public);
base_command.args(["-public", &public]);

// Sets the save interval in seconds
if let Some(save_interval) = &config.save_interval {
base_command.arg(format!("-saveinterval {}", save_interval));
let interval = save_interval.to_string();
debug!("Setting save interval to: {}", &interval);
base_command.args(["-saveinterval", &interval]);
};

// Add set_key to the command
if let Some(set_key) = &config.set_key {
base_command.arg(format!("-setkey {}", set_key));
debug!("Setting set_key to: {}", &set_key);
base_command.args(["-setkey", &set_key]);
};

// Add preset to the command
if let Some(preset) = &config.preset {
base_command.arg(format!("-preset {}", preset));
debug!("Setting preset to: {}", &preset);
base_command.args(["-preset", &preset]);
};

// Add modifiers to the command
if let Some(modifiers) = &config.modifiers {
base_command.args(
modifiers
.iter()
.map(|modifier| format!("-modifier {} {}", modifier.name, modifier.value)),
);
modifiers.iter().for_each(|modifier| {
debug!(
"Setting modifier to: {} {}",
&modifier.name, &modifier.value
);
base_command.args(["-modifier", &modifier.name, &modifier.value]);
});
};

// Extra args for the server
let extra_args = format!(
"-nographics -batchmode {}",
fetch_var("SERVER_EXTRA_LAUNCH_ARGS", "")
)
.trim()
.to_string();
base_command.arg(extra_args);
base_command.args({
format!(
"-nographics -batchmode {}",
fetch_var("SERVER_EXTRA_LAUNCH_ARGS", "")
)
.trim()
.to_string()
.split(' ')
.collect::<Vec<&str>>()
});

let is_public = config.public.eq("1");
let is_vanilla = fetch_var("TYPE", "vanilla").eq_ignore_ascii_case("vanilla");
Expand All @@ -123,18 +138,19 @@ pub fn start(config: ValheimArguments) -> CommandResult {
exit(1)
} else {
info!("Password found, adding password flag.");
base_command = base_command.arg(format!("-password {}", config.password));
base_command.arg("-password");
base_command.arg(&config.password);
}

if fetch_var("ENABLE_CROSSPLAY", "0").eq("1") {
info!("Launching with Crossplay! <3");
base_command = base_command.arg("-crossplay")
base_command.arg("-crossplay");
} else {
info!("No Crossplay Enabled!")
}

// Tack on save dir at the end.
base_command = base_command.arg(format!("-savedir {}", &saves_directory()));
base_command.args(["-savedir", &saves_directory()]);

debug!("Base Command: {:#?}", base_command);

Expand Down
Loading