-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
65 lines (56 loc) · 1.39 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh
tag=0.0.1
os=$(uname -s | sed -e 's/\(.*\)/\L\1/')
arch=$(uname -m)
case "$os" in
"linux"|"darwin")
echo "fetching latest revision..."
if [ "$arch" == "x86_64" ]; then
arch="amd64"
else
arch="386"
fi
filename="terraform-provider-gd.$os.$arch"
cd /tmp && curl -fOsSL https://github.com/barneyparker/terraform-provider-gd/releases/download/v$tag/$filename.tgz 2>/dev/null
if [ ! -f /tmp/$filename.tgz ]; then
echo "Install failed"
exit 1
else
cd /tmp && gzip -dc $filename.tgz | tar xf -
fi
if [ ! -f terraform-provider-gd ]; then
echo "Archive extract failed"
exit 1
fi
;;
*)
echo "Unable to download and install for this platform ($os / $arch)"
exit 1
;;
esac
printf "Installing terraform-provider-gd binary..."
mkdir -p ~/.terraform/plugins && mv terraform-provider-gd ~/.terraform/plugins
if [ $? -eq 0 ]; then
echo "Complete"
else
echo "Failed"
exit 1
fi
printf "Configuring Terraform..."
if [ -f ~/.terraformrc ]; then
if [[ $(grep "gd" ~/.terraformrc) ]]; then
echo "Complete"
else
echo "\nPlease add the following line to your terraform config:"
echo ""
echo "\tgd = \"$HOME/.terraform/plugins/terraform-provider-gd\""
echo ""
fi
else
cat > ~/.terraformrc <<EOF
providers {
gd = "$HOME/.terraform/plugins/terraform-provider-gd"
}
EOF
echo "Complete"
fi