forked from nasa/harmony
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-dotenv
executable file
·66 lines (56 loc) · 2.56 KB
/
create-dotenv
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
#!/bin/sh
if [ -f .env ]; then
echo "Skipping generating .env file because it already exists."
else
cat <<-EOF > .env
# Random string used to sign cookies.
COOKIE_SECRET=$(hexdump -n 128 -e '"%08x"' /dev/random)
# Random string used for encrypting and decrypting Earthdata login tokens
# sent to backend services
SHARED_SECRET_KEY=$(hexdump -n 16 -e '"%08x"' /dev/random)
EOF
cat <<-PROMPT_EDL
Running Harmony requires creating an Earthdata Login (EDL) application. If you need instructions for this or do not understand what this means, please contact the Harmony team for help. Once you have your EDL application created, please enter the credentials as prompted.
PROMPT_EDL
echo "# See the \"OAuth 2 (Earthdata Login)\" section in the env-defaults file" >> .env
echo "# Contact a harmony developer if unsure what values to use" >> .env
# prompt for the users EDL app credentials
read -p "EDL Application Client ID: " OAUTH_CLIENT_ID
read -s -p "EDL Application UID: " OAUTH_UID
echo ""
read -s -p "EDL Application Password: " OAUTH_PASSWORD
echo ""
cat <<-EOF >> .env
OAUTH_CLIENT_ID=$OAUTH_CLIENT_ID
OAUTH_UID=$OAUTH_UID
OAUTH_PASSWORD=$OAUTH_PASSWORD
EOF
# prompt for HOST_VOLUME_PATH
echo "\nEnter the full path to the directory to use for service metadata output."
echo "The directory MUST be under your home directory and will be created if it does not exist."
read -p "Hit <Enter> for <${HOME}/metadata>: " HOST_VOLUME_PATH
echo ""
echo "\n# Env vars used for turbo mode" >> .env
# Add HOST_VOLUME_PATH if it is defined (not zero length)
if [ ! -z "${HOST_VOLUME_PATH}" ]; then
echo "HOST_VOLUME_PATH=${HOST_VOLUME_PATH}" >> .env
mkdir -p "${HOST_VOLUME_PATH}"
else
echo "HOST_VOLUME_PATH=${HOME}/metadata" >> .env
mkdir -p "${HOME}/metadata"
fi
# prompt for LOCALLY_DEPLOYED_SERVICES
echo "Enter services to deploy (comma separated list):"
read -p "Hit <Enter> to use the default services: " LOCALLY_DEPLOYED_SERVICES
# Add locally LOCALLY_DEPLOYED_SERVICES if it is defined (not zero length)
if [ ! -z "${LOCALLY_DEPLOYED_SERVICES}" ]; then
echo "LOCALLY_DEPLOYED_SERVICES=${LOCALLY_DEPLOYED_SERVICES}\n" >> .env
fi
OS=`uname`
if [ "Linux" = "$OS" ]; then
echo "\n# Detected running on Linux so setting Linux specific env" >> .env
echo "CALLBACK_URL_ROOT=http://localhost:3001" >> .env
echo "BACKEND_HOST=localhost" >> .env
echo "KUBE_CONTEXT=minikube" >> .env
fi
fi