forked from n3integration/terraform-provider-godaddy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·73 lines (63 loc) · 1.55 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
66
67
68
69
70
71
72
73
#!/bin/sh
version=1.7.0
os=$(uname -s | tr '[:upper:]' '[:lower:]')
mach=$(uname -m)
plugin="terraform-godaddy"
case "$os" in
"linux"|"darwin")
printf "[info] fetching latest revision..."
if [ "$mach" == "x86_64" ]; then
arch="amd64"
else
arch="386"
fi
file=$(printf "%s_%s_%s" $plugin $os $arch)
archive="$file.tgz"
cd /tmp && curl -fOsSL https://github.com/n3integration/$plugin/releases/download/v$version/$archive 2>/dev/null
if [ ! -f /tmp/$archive ]; then
echo "ERROR"
echo "\t-> failed to download file"
exit 1
else
cd /tmp && gzip -dc $archive | tar xf -
mv $file $plugin
fi
if [ -f $plugin ]; then
echo "OK"
else
echo "ERROR"
echo "\t-> failed to extract file contents"
exit 1
fi
;;
*)
echo "[error] Dagger. It doesn't look like your OS is currently supported. Please submit an issue or pull request."
exit 1
;;
esac
printf "[info] installing plugin..."
mkdir -p ~/.terraform/plugins && mv $plugin ~/.terraform/plugins
if [ $? -eq 0 ]; then
echo "OK"
else
exit 1
fi
if [ -f ~/.terraformrc ]; then
if [[ $(grep "godaddy" ~/.terraformrc) ]]; then
echo "[info] complete"
else
echo "[info] append the godaddy provider to your ~/.terraformrc configuration file"
echo ""
echo "providers {"
echo "\tgodaddy = \"$HOME/.terraform/plugins/$plugin\""
echo "}"
echo ""
fi
else
cat > ~/.terraformrc <<EOF
providers {
godaddy = "$HOME/.terraform/plugins/$plugin"
}
EOF
echo "[info] complete"
fi