networking-configuration -> lib/cacnixos.sh
This commit is contained in:
parent
1cc154e1a2
commit
c5b8e0d368
3
infest
3
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 '(
|
||||
|
|
37
networking-configuration → lib/cacnixos.sh
Executable file → Normal file
37
networking-configuration → lib/cacnixos.sh
Executable file → Normal file
|
@ -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
|
||||
# cacnixos_networking : cac-server x hostname -> nixos-module
|
||||
cacnixos_networking() {(
|
||||
server=$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() {
|
||||
server=$1
|
||||
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 "$@"
|
||||
)}
|
Loading…
Reference in a new issue