Tinkerbell.Sandbox/deploy/vagrant/scripts/tinkerbell.sh

57 lines
1.0 KiB
Bash
Raw Normal View History

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"
)
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
if [ ! -f ./.env ]; then
./generate-env.sh eth1 >.env
2020-08-20 11:53:27 +00:00
fi
# shellcheck disable=SC1091
. ./.env
2020-08-20 11:53:27 +00:00
make_certs_writable
./setup.sh
if [[ ${TINKERBELL_CONFIGURE_NAT:=true} != "false" ]]; then
setup_nat
fi
2020-08-20 11:53:27 +00:00
secure_certs
configure_vagrant_user
)
main