-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
77 lines (69 loc) · 2.4 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
74
75
76
#!/usr/bin/env bash
#
# Install script to deploy dikhao as a heroku application
# Author - @rohit01
echo -e "Input heroku application name: \c"
read app_name
if [ "X${app_name}" = "X" ]; then
echo "ERROR: Application name cannot be blank. Aborting!"
exit 2
fi
################# Verify if heroku toolbelt is installed #################
if ! type heroku >/dev/null 2>&1; then
echo "Installing Heroku CLI toolbelt..."
sleep 1
wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh
fi
##################### Compute rediscloud credentials #####################
echo "Creating application ${app_name}..."
if ! heroku create ${app_name} -s cedar --addons rediscloud:25; then
echo "ERROR: Application create failed. Aborting!"
exit 1
fi
REDISCLOUD_URL=`heroku config:get REDISCLOUD_URL`
if [ "X${REDISCLOUD_URL}" = "X" ]; then
echo "ERROR: rediscloud credentials not found. Aborting!"
exit 2
fi
REDISCLOUD_URL=${REDISCLOUD_URL/redis:\/\/rediscloud:/}
REDIS_PASSWORD=${REDISCLOUD_URL/@*/}
REDISCLOUD_URL=${REDISCLOUD_URL/*@/}
REDIS_HOSTNAME=${REDISCLOUD_URL/:*/}
REDIS_PORT=${REDISCLOUD_URL/*:/}
unset REDISCLOUD_URL
############################## Deploy code ##############################
echo "Deploying code in heroku..."
if git push heroku master; then
echo "Code successfully deployed in heroku."
else
echo "ERROR: Operation failed. Aborting!"
exit 3
fi
######################## Configure application ##########################
echo "...CONFIGURE APPLICATION..."
echo ""
echo -e "Input AWS Access key id: \c"
read AWS_ACCESS_KEY_ID
echo -e "Input AWS secret access key: \c"
read AWS_SECRET_ACCESS_KEY
echo -e "Input SENTRY_DSN for exception tracking by Sentry: \c"
read SENTRY_DSN
echo "Setting AWS and rediscloud settings..."
heroku config:set AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}"
heroku config:set AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}"
if [ "X${SENTRY_DSN}" != "X" ]; then
heroku config:set SENTRY_DSN="${SENTRY_DSN}"
fi
heroku config:set REDIS_HOST="${REDIS_HOSTNAME}"
heroku config:set REDIS_PORT_NO="${REDIS_PORT}"
heroku config:set REDIS_PASSWORD="${REDIS_PASSWORD}"
heroku config:set PORT="80"
echo ""
echo "Configuration complete."
echo ""
echo "Application url: http://${app_name}.herokuapp.com"
echo "Useful links:"
echo ""
echo "Sync data from AWS: http://${app_name}.herokuapp.com/sync"
echo "Perform lookups: http://${app_name}herokuapp.com/lookup/<search_key>"
echo ""