server.garden privileged automation agent (mirror of https://git.sequentialread.com/forest/rootsystem)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
2.0 KiB

#!/bin/bash
which ansible
if [ "$?" == "1" ]; then
echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu bionic main" > /etc/apt/sources.list.d/ansible.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367
apt update
apt install -y ansible
#apt install -y python3-pip
#pip3 install ansible
fi
which dot
if [ "$?" == "1" ]; then
apt install -y graphviz
fi
which terraform
TERRAFORM_VERSION='missing'
if [ "$?" == "0" ]; then
TERRAFORM_VERSION="$(terraform version | head -n 1 | sed -E 's|(.?)*([0-9]+\.[0-9]+\.[0-9]+).*|\2|')"
fi
DESIRED_TERRAFORM_VERSION="0.12.29"
TERRAFORM_ARCH="arm"
echo "TERRAFORM_VERSION $TERRAFORM_VERSION"
if [ "$TERRAFORM_VERSION" != "$DESIRED_TERRAFORM_VERSION" ]; then
if [ "$TERRAFORM_VERSION" != "missing" ]; then
rm /usr/bin/terraform
fi
# curl "https://releases.hashicorp.com/terraform/0.12.29/terraform_0.12.29_linux_amd64.zip" > "terraform_0.12.29_linux_amd64.zip"
curl "https://releases.hashicorp.com/terraform/$DESIRED_TERRAFORM_VERSION/terraform_$DESIRED_TERRAFORM_VERSION""_linux_$TERRAFORM_ARCH.zip" > "terraform_$DESIRED_TERRAFORM_VERSION""_linux_$TERRAFORM_ARCH.zip"
unzip "terraform_$DESIRED_TERRAFORM_VERSION""_linux_$TERRAFORM_ARCH.zip"
rm "terraform_$DESIRED_TERRAFORM_VERSION""_linux_$TERRAFORM_ARCH.zip"
mv terraform /usr/bin/terraform
fi
# if [ ! -f ~/.terraform.d/plugins/linux_arm/terraform-provider-gandi ]; then
# curl https://f000.backblazeb2.com/file/server-garden-artifacts/terraform-provider-gandi-arm.tar.gz > terraform-provider-gandi-arm.tar.gz
# tar -xvf terraform-provider-gandi-arm.tar.gz
# rm terraform-provider-gandi-arm.tar.gz
# mkdir -p ./.terraform.d/plugins/linux_arm/
# mv terraform-provider-gandi ./.terraform.d/plugins/linux_arm/terraform-provider-gandi
# fi
rm -rf rootsystem
curl https://f000.backblazeb2.com/file/server-garden-artifacts/rootsystem-arm.tar.gz > rootsystem-arm.tar.gz
tar -xvf rootsystem-arm.tar.gz
rm rootsystem-arm.tar.gz
cp secret/config.json rootsystem/config.json
cp -r secret/ssh rootsystem/ssh