-
Notifications
You must be signed in to change notification settings - Fork 69
/
config.sh
executable file
·74 lines (66 loc) · 1.96 KB
/
config.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
#!/bin/bash
# Deploy will terminate on any error
set -e
# Firebase Working directory
projectDir="`dirname \"$0\"`"
cd "$projectDir" || exit 1
projectDir="`pwd`"
#
# Scanning and installing dependencies
# (Assuming a mac)
#
if [ -z "$(which envsubst)" ]; then
if [ -z "$(which brew)" ]; then
echo ">> envsubst not detected : please install =["
else
echo ">> envsubst not detected : using brew to install"
brew install gettext
brew link --force gettext
fi
fi
if [ -z "$(which npm)" ]; then
echo ">> NPM not detected : please install =["
exit 1;
fi
if [ -z "$(which node)" ]; then
echo ">> node not detected : please install =["
exit 1;
fi
if [ -z "$(which go)" ]; then
echo ">> go not detected : please install =["
exit 1;
fi
#
# Getting the various configuration settings from command line / environment variable
#
if [ -z "$MAILGUN_EMAIL_DOMAIN" ]; then
echo ">> Please type in your MAILGUN_EMAIL_DOMAIN (eg: inboxkitten.com)";
read -p '>> MAILGUN_EMAIL_DOMAIN : ' MAILGUN_EMAIL_DOMAIN;
else
echo ">> Detected MAILGUN_EMAIL_DOMAIN env variable : $MAILGUN_EMAIL_DOMAIN";
fi
if [ -z "$WEBSITE_DOMAIN" ]; then
echo ">> Please type in your WEBSITE_DOMAIN (eg: inboxkitten.com)";
read -p '>> WEBSITE_DOMAIN : ' WEBSITE_DOMAIN;
else
echo ">> Detected WEBSITE_DOMAIN env variable : $WEBSITE_DOMAIN";
fi
if [ -z "$MAILGUN_API_KEY" ]; then
echo ">> Please type in your MAILGUN_API_KEY";
read -sp '>> MAILGUN_API_KEY : ' MAILGUN_API_KEY;
echo "";
else
echo ">> Detected MAILGUN_API_KEY env variable : [intentionally redacted]";
fi
#
# Exporting variables, for envsubst support
#
export MAILGUN_EMAIL_DOMAIN="$MAILGUN_EMAIL_DOMAIN"
export MAILGUN_API_KEY="$MAILGUN_API_KEY"
export WEBSITE_DOMAIN="$WEBSITE_DOMAIN"
#
# Applying the configuration
#
echo ">> Applying config settings"
cat "$projectDir/api/config/mailgunConfig.sample.js" | envsubst > "$projectDir/api/config/mailgunConfig.js"
cat "$projectDir/ui/config/apiconfig.sample.js" | envsubst > "$projectDir/ui/config/apiconfig.js"