35 lines
1.1 KiB
Nix
35 lines
1.1 KiB
Nix
{ writeShellScriptBin, envsubst }:
|
|
|
|
writeShellScriptBin "netali-default-config-ruby" ''
|
|
if [[ $# -ne 6 ]]; then
|
|
echo "Usage: netali-default-config-ruby [out-path] [hostname] [interface] [last-ip-block] [mode] [state-version]"
|
|
echo ""
|
|
echo "out-path: path to which the configuration will be written"
|
|
echo "hostname: hostname of the new host"
|
|
echo "interface: name of the network interface to configure"
|
|
echo "last-ip-block: last block of the IPv6 address of this host"
|
|
echo "mode: 'public' or 'internal' (affects IP subnet)"
|
|
echo "state-version: NixOS State Version"
|
|
exit 1
|
|
fi
|
|
|
|
OUT_PATH=$1
|
|
export TARGET_HOSTNAME="$2"
|
|
export INTERFACE=$3
|
|
export LAST_IP_BLOCK=$4
|
|
MODE=$5
|
|
export STATE_VERSION=$6
|
|
|
|
if [[ $MODE == "public" ]]; then
|
|
export PREFIX="2a00:fe0:1:21f::"
|
|
export GATEWAY="2a00:fe0:1:21f::1"
|
|
else
|
|
export PREFIX="2a00:fe0:3f5:1000::"
|
|
export GATEWAY="2a00:fe0:3f5:1000::1"
|
|
fi
|
|
|
|
cp ${./static.nix} $OUT_PATH/static.nix
|
|
chmod 644 $OUT_PATH/static.nix
|
|
${envsubst}/bin/envsubst -i ${./config-template.txt} -o $OUT_PATH/configuration.nix
|
|
''
|