2020-08-20 11:53:27 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# abort this script on errors
|
|
|
|
set -euxo pipefail
|
|
|
|
|
|
|
|
whoami
|
|
|
|
|
|
|
|
cd /vagrant
|
|
|
|
|
|
|
|
make_certs_writable() (
|
|
|
|
local certdir="/etc/docker/certs.d/$TINKERBELL_HOST_IP"
|
|
|
|
sudo mkdir -p "$certdir"
|
|
|
|
sudo chown -R "$USER" "$certdir"
|
|
|
|
)
|
|
|
|
|
|
|
|
secure_certs() (
|
|
|
|
local certdir="/etc/docker/certs.d/$TINKERBELL_HOST_IP"
|
|
|
|
sudo chown "root" "$certdir"
|
|
|
|
)
|
|
|
|
|
|
|
|
configure_vagrant_user() (
|
|
|
|
echo -n "$TINKERBELL_REGISTRY_PASSWORD" |
|
|
|
|
sudo -iu vagrant docker login \
|
|
|
|
--username="$TINKERBELL_REGISTRY_USERNAME" \
|
|
|
|
--password-stdin "$TINKERBELL_HOST_IP"
|
|
|
|
)
|
|
|
|
|
2021-01-22 08:35:16 +00:00
|
|
|
setup_nat() (
|
|
|
|
iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
|
|
|
|
iptables -A FORWARD -i eth0 -o eth1 -m state --state ESTABLISHED,RELATED -j ACCEPT
|
|
|
|
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
|
|
|
|
)
|
|
|
|
|
2020-08-20 11:53:27 +00:00
|
|
|
main() (
|
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
|
|
|
2020-09-14 09:27:20 +00:00
|
|
|
if [ ! -f ./.env ]; then
|
2020-11-09 22:16:43 +00:00
|
|
|
./generate-envrc.sh eth1 >.env
|
2020-08-20 11:53:27 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# shellcheck disable=SC1091
|
2020-09-14 09:27:20 +00:00
|
|
|
. ./.env
|
2020-08-20 11:53:27 +00:00
|
|
|
|
|
|
|
make_certs_writable
|
|
|
|
|
|
|
|
./setup.sh
|
|
|
|
|
2021-03-17 20:32:18 +00:00
|
|
|
if [[ ${TINKERBELL_CONFIGURE_NAT:=true} != "false" ]]; then
|
|
|
|
setup_nat
|
|
|
|
fi
|
|
|
|
|
2020-08-20 11:53:27 +00:00
|
|
|
secure_certs
|
|
|
|
configure_vagrant_user
|
|
|
|
)
|
|
|
|
|
|
|
|
main
|