summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2015-05-20 22:16:48 +0200
committertv <tv@krebsco.de>2015-05-20 22:16:48 +0200
commit0bb1b4493d2f24c89159121289a412ae3aa58576 (patch)
treed3d788592953c0d520357062c406fa3a5dd8615f
parentc05afbe81aec1b3629c9527b4d9cd8f54f97943a (diff)
networking-configuration -> lib/cacnixos.sh
-rwxr-xr-xinfest3
-rw-r--r--[-rwxr-xr-x]lib/cacnixos.sh (renamed from networking-configuration)39
2 files changed, 7 insertions, 35 deletions
diff --git a/infest b/infest
index dc5e540..2c02b13 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
index 0e105b4..24502d6 100755..100644
--- 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 "$@"
+)}