From e348549800bbd8e2ca31fbc13203e72ad7442201 Mon Sep 17 00:00:00 2001 From: trivernis Date: Sun, 12 Mar 2023 21:05:55 +0100 Subject: [PATCH] Add configure network implementation --- configs/crystal/configure-network/up.nu | 30 +++++++++++++++++++- configs/crystal/configure-unakite/up.nu | 1 + configs/crystal/install-extra-packages/up.nu | 2 ++ configs/crystal/install-timeshift/up.nu | 1 + configs/crystal/install-zramd/up.nu | 1 + configs/crystal/setup-root-user/up.nu | 1 + configs/crystal/setup-users/up.nu | 1 + 7 files changed, 36 insertions(+), 1 deletion(-) diff --git a/configs/crystal/configure-network/up.nu b/configs/crystal/configure-network/up.nu index 2ffcb1a..a80dd45 100644 --- a/configs/crystal/configure-network/up.nu +++ b/configs/crystal/configure-network/up.nu @@ -1,5 +1,33 @@ let RUN_IN_CHROOT = true; + +def set_hostname [hostname: string] { + debug $"Setting host name to ($hostname)" + touch /etc/hostname + $"\n($hostname)\n" | save -a /etc/hostname +} + +def create_hosts [] { + debug "Configuring hosts file" + touch /etc/hosts + "\n127.0.0.1 localhost\n" | save -a /etc/hosts +} + +def create_ipv6_loopback [] { + debug "Creating ipv6 loopback" + touch /etc/hosts + "\n::1 localhost\n" | save -a /etc/hosts +} + # Applies all system changes of `configure-network` def main [cfg] { - echo "Executing up task `configure-network` with config" $cfg + debug $"Configuring network with config ($cfg)" + + set_hostname $cfg.hostname + create_hosts + + if $cfg.ipv6_loopback { + create_ipv6_loopback + } + + info "Configured network" } diff --git a/configs/crystal/configure-unakite/up.nu b/configs/crystal/configure-unakite/up.nu index d4dcc63..a8f0e1a 100644 --- a/configs/crystal/configure-unakite/up.nu +++ b/configs/crystal/configure-unakite/up.nu @@ -2,4 +2,5 @@ let RUN_IN_CHROOT = true; # Applies all system changes of `configure-unakite` def main [cfg] { echo "Executing up task `configure-unakite` with config" $cfg + todo "Implement configure-unakite" } diff --git a/configs/crystal/install-extra-packages/up.nu b/configs/crystal/install-extra-packages/up.nu index fad7ecd..c64efc9 100644 --- a/configs/crystal/install-extra-packages/up.nu +++ b/configs/crystal/install-extra-packages/up.nu @@ -2,4 +2,6 @@ let RUN_IN_CHROOT = true; # Applies all system changes of `install-extra-packages` def main [cfg] { echo "Executing up task `install-extra-packages` with config" $cfg + todo "Implement install-extra packages" } + diff --git a/configs/crystal/install-timeshift/up.nu b/configs/crystal/install-timeshift/up.nu index fb907ed..50e0fff 100644 --- a/configs/crystal/install-timeshift/up.nu +++ b/configs/crystal/install-timeshift/up.nu @@ -2,4 +2,5 @@ let RUN_IN_CHROOT = true; # Applies all system changes of `install-timeshift` def main [cfg] { echo "Executing up task `install-timeshift` with config" $cfg + todo "Implement install-timeshift" } diff --git a/configs/crystal/install-zramd/up.nu b/configs/crystal/install-zramd/up.nu index 02daee8..9e764bb 100644 --- a/configs/crystal/install-zramd/up.nu +++ b/configs/crystal/install-zramd/up.nu @@ -2,4 +2,5 @@ let RUN_IN_CHROOT = true; # Applies all system changes of `install-zramd` def main [cfg] { echo "Executing up task `install-zramd` with config" $cfg + todo "Implement install-zdramd" } diff --git a/configs/crystal/setup-root-user/up.nu b/configs/crystal/setup-root-user/up.nu index c51015e..0e5f0da 100644 --- a/configs/crystal/setup-root-user/up.nu +++ b/configs/crystal/setup-root-user/up.nu @@ -2,4 +2,5 @@ let RUN_IN_CHROOT = true; # Applies all system changes of `setup-root-user` def main [cfg] { echo "Executing up task `setup-root-user` with config" $cfg + todo "Implement setup-root-user" } diff --git a/configs/crystal/setup-users/up.nu b/configs/crystal/setup-users/up.nu index b2bb378..84f251a 100644 --- a/configs/crystal/setup-users/up.nu +++ b/configs/crystal/setup-users/up.nu @@ -2,4 +2,5 @@ let RUN_IN_CHROOT = true; # Applies all system changes of `setup-users` def main [cfg] { echo "Executing up task `setup-users` with config" $cfg + todo "Implement setup-users" }