diff --git a/infest b/infest index dc5e54070..2c02b13c2 100755 --- a/infest +++ b/infest @@ -3,6 +3,7 @@ set -xeuf . ./lib/prelude.sh . ./lib/cac.sh +. ./lib/cacnixos.sh nix_url=https://nixos.org/releases/nix/nix-1.8/nix-1.8-x86_64-linux.tar.bz2 nix_sha256=52fab207b4ce4d098a12d85357d0353e972c492bab0aa9e08e1600363e76fefb @@ -54,7 +55,7 @@ infest_centos7_64bit() { main="modules/$hostname/default.nix" target="root@$address" - ./networking-configuration $cac_servername $hostname \ + cacnixos_networking "$server" $hostname \ > modules/$hostname/networking.nix echo '( diff --git a/networking-configuration b/lib/cacnixos.sh old mode 100755 new mode 100644 similarity index 52% rename from networking-configuration rename to lib/cacnixos.sh index 0e105b45f..24502d694 --- a/networking-configuration +++ b/lib/cacnixos.sh @@ -1,43 +1,16 @@ -#! /bin/sh -# -# usage: with cac ./networking-configuration c838-828 cd -# -set -euf - -. ./lib/cac.sh . ./lib/net.sh -cac_servername=$1 -hostname=$2 - -# This is somewhat required because cloudatcost requires whitelisting -# of hosts. If you whitelist your localhost, then leave this empty. -# cac_via= -# -# cac_key= -# cac_login= -# cac_servername= - -# hostname= - -main() {( - server=$(cac_getserver_by_servername "$cac_servername") - print_networking_configuraton "$server" -)} - - -print_networking_configuraton() { +# cacnixos_networking : cac-server x hostname -> nixos-module +cacnixos_networking() {( server=$1 + hostname=$2 + address=$(echo $server | jq -r .ip) gateway=$(echo $server | jq -r .gateway) nameserver=8.8.8.8 netmask=$(echo $server | jq -r .netmask) prefix=$(net_netmask_to_prefix $netmask) - # TODO generate all config and put it into a temp dir, then rsync that - # - # upload configuration (to /root) - # printf '{...}:\n' printf '{\n' printf ' networking.hostName = "%s";\n' $hostname @@ -52,6 +25,4 @@ print_networking_configuraton() { printf ' "%s"\n' $nameserver printf ' ];\n' printf '}\n' -} - -main "$@" +)}