#!/bin/sh
cd $AUTOPKGTEST_TMP
echo "create certificate authority"
nebula-cert ca -name "Autopkgtest CA"
echo "create and sign node certificate"
nebula-cert sign -ca-key ca.key -ca-crt ca.crt -name "Autopkgtest Node" -ip "127.0.0.1/0" -out-crt node.crt -out-key node.key
echo "create node config"
cat <<EOF > node.yaml
pki:
  ca: ca.crt
  cert: node.crt
  key: node.key
static_host_map:
 "127.0.0.1": ["localhost:4242"]
lighthouse:
  interval: 60
  am_lighthouse: false
listen:
  host: 0.0.0.0
  port: 4242
EOF
echo "test configuration"
nebula -test -config node.yaml
cp $AUTOPKGTEST_TMP/*.key $AUTOPKGTEST_TMP/*.crt $AUTOPKGTEST_ARTIFACTS/
