Skip to content

Commit

Permalink
Set hostname when applying network config (#18)
Browse files Browse the repository at this point in the history
Signed-off-by: Atanas Dinov <[email protected]>
  • Loading branch information
atanasdinov authored Nov 24, 2023
1 parent d0946b3 commit 2c04b6c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/apply_conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::types::Host;
use crate::HOST_MAPPING_FILE;

const CONNECTION_FILE_EXT: &str = "nmconnection";
const HOSTNAME_FILE: &str = "/etc/hostname";

pub(crate) fn apply(source_dir: &str, destination_dir: &str) -> Result<(), anyhow::Error> {
let hosts = parse_config(source_dir).context("Parsing config")?;
Expand All @@ -24,6 +25,8 @@ pub(crate) fn apply(source_dir: &str, destination_dir: &str) -> Result<(), anyho
.ok_or_else(|| anyhow!("None of the preconfigured hosts match local NICs"))?;
info!("Identified host: {}", host.hostname);

fs::write(HOSTNAME_FILE, &host.hostname).context("Setting hostname")?;

copy_connection_files(host, &network_interfaces, source_dir, destination_dir)
}

Expand Down

0 comments on commit 2c04b6c

Please sign in to comment.