-
Notifications
You must be signed in to change notification settings - Fork 100
/
start.sh
executable file
·142 lines (130 loc) · 4.75 KB
/
start.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/usr/bin/env bash
set -o errexit # abort on nonzero exit status
set -o nounset # abort on unbound variable
set -o pipefail # don't hide errors within pipes
# Don't pollute console output with upgrade notifications
export PULUMI_SKIP_UPDATE_CHECK=true
# Run Pulumi non-interactively
export PULUMI_SKIP_CONFIRMATIONS=true
# Unset virtual environment if defined....
unset VIRTUAL_ENV
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
# Check to see if the venv has been installed, since this is only going to be used to start pulumi/python based
# projects.
#
if ! command -v "${script_dir}/../pulumi/python/venv/bin/python" >/dev/null; then
echo "NOTICE! Unable to find the venv directory. This is required for the pulumi/python deployment process."
echo "Please run ./setup_venv.sh from this directory to install the required virtual environment."
echo " "
exit 1
else
echo "Adding to [${script_dir}/venv/bin] to PATH"
export PATH="${script_dir}/../pulumi/python/venv/bin:$PATH"
fi
if ! command -v pulumi >/dev/null; then
if [ -x "${script_dir}/../pulumi/python/venv/bin/pulumi" ]; then
echo "Adding to [${script_dir}/venv/bin] to PATH"
export PATH="${script_dir}/../pulumi/python/venv/bin:$PATH"
if ! command -v pulumi >/dev/null; then
echo >&2 "Pulumi must be installed to continue"
exit 1
fi
else
echo >&2 "Pulumi must be installed to continue"
exit 1
fi
fi
if ! command -v python3 >/dev/null; then
echo >&2 "Python 3 must be installed to continue"
exit 1
fi
# Check to see if the user is logged into Pulumi
if ! pulumi whoami --non-interactive >/dev/null 2>&1; then
pulumi login
if ! pulumi whoami --non-interactive >/dev/null 2>&1; then
echo >&2 "Unable to login to Pulumi - exiting"
exit 2
fi
fi
echo " "
echo "NOTICE! This shell script is maintained for compatibility for the kubeconfig only deployment and will be"
echo "deprecated once the kubeconfig deployments are fully integrated with the automation api."
echo " "
echo "If you are deploying AWS, DigitalOcean, or Linode based stacks you will need to use the runner script."
echo " "
echo "Please read the documentation for more details."
echo " "
# Sleep so we are seen...
sleep 5
if [ -s "${script_dir}/../config/pulumi/environment" ] && grep --quiet '^PULUMI_STACK=.*' "${script_dir}/../config/pulumi/environment"; then
source "${script_dir}"/../config/pulumi/environment
echo "Environment data found for stack: ${PULUMI_STACK}"
while true; do
read -r -e -p "Environment file exists and is not empty. Answer yes to use, no to delete. " yn
case $yn in
[Yy]*) # We have an environment file, and they want to keep it....
if pulumi config get kubernetes:infra_type -C "${script_dir}"/../pulumi/python/config >/dev/null 2>&1; then
INFRA=$(pulumi config get kubernetes:infra_type -C "${script_dir}"/../pulumi/python/config)
if [ "$INFRA" == 'AWS' ]; then
echo "This script no longer works with AWS deployments; please use ./pulumi/python/runner instead"
exec "${script_dir}"/../pulumi/python/runner
exit 0
elif [ "$INFRA" == 'kubeconfig' ]; then
exec "${script_dir}"/start_kube.sh
exit 0
elif [ "$INFRA" == 'DO' ]; then
echo "This script no longer works with DigitalOcean deployments; please use ./pulumi/python/runner instead"
exec "${script_dir}"/../pulumi/python/runner
exit 0
elif [ "$INFRA" == 'LKE' ]; then
echo "This script no longer works with Linode deployments; please use ./pulumi/python/runner instead"
exec "${script_dir}"/../pulumi/python/runner
exit 0
else
echo "Corrupt or non-existent configuration file, please restart and delete and reconfigure."
exit 1
fi
else
echo "Corrupt or non-existent configuration file, please restart and delete and reconfigure."
exit 1
fi
break
;;
[Nn]*) # They want to remove and reconfigure
rm -f "${script_dir}"/../config/pulumi/environment
break
;;
*) echo "Please answer yes or no." ;;
esac
done
fi
while true; do
read -e -r -p "Type a for AWS, d for Digital Ocean, k for kubeconfig, l for Linode? " infra
case "$infra" in
[Aa]*)
echo "This script no longer works with AWS deployments; please use ./pulumi/python/runner instead"
exec "${script_dir}"/../pulumi/python/runner
exit 0
break
;;
[Kk]*)
echo "Calling kubeconfig startup script"
exec "${script_dir}"/start_kube.sh
exit 0
break
;;
[Dd]*)
echo "This script no longer works with DigitalOcean deployments; please use ./pulumi/python/runner instead"
exec "${script_dir}"/../pulumi/python/runner
exit 0
break
;;
[Ll]*)
echo "This script no longer works with Linode deployments; please use ./pulumi/python/runner instead"
exec "${script_dir}"/../pulumi/python/runner
exit 0
break
;;
*) echo "Please answer a, d, k, or l." ;;
esac
done