-
Notifications
You must be signed in to change notification settings - Fork 2
/
install-automation-agent.sh
49 lines (39 loc) · 1.59 KB
/
install-automation-agent.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
#!/bin/bash
# Expects $MMS_GROUP_ID and $MMS_AGENT_APIKEY
# MMS_USER, and MMS_APIKEY
#TODO: Error if environment varibles not set.
AGENT_URL=${MMS_BASE_URL_INTERNAL}/download/agent/automation/
AGENT=mongodb-mms-automation-agent-manager-
# TODO - How to discover this download???? can't find in api
#AGENT_VERSION=3.2.14.2187-1.x86_64.rhel7.rpm
AGENT_VERSION=4.5.11.2453-1.x86_64.rhel7.rpm
# We need to auto-detect the automation agent versions
# available for us to download
echo "Downloading $AGENT_URL$AGENT$AGENT_VERSION"
curl -OL "$AGENT_URL$AGENT$AGENT_VERSION"
echo "Installing $AGENT$AGENT_VERSION"
rpm -U $AGENT$AGENT_VERSION
echo "Updating /etc/mongodb-mms/automation-agent.config with:"
echo "mmsGroupId=${MMS_GROUP_ID}"
echo "mmsApiKey=${MMS_AGENT_APIKEY}"
echo "mmsBaseUrl=${MMS_BASE_URL_INTERNAL}"
cat << ENDMMS >> /etc/mongodb-mms/automation-agent.config
# ############################################
# Automatically updated on: `date`
#
# DO NOT EDIT!
#
# ############################################
mmsGroupId=${MMS_GROUP_ID}
mmsApiKey=${MMS_AGENT_APIKEY}
mmsBaseUrl=${MMS_BASE_URL_INTERNAL}
ENDMMS
chown mongod:mongod /data
echo "Creating /var/run/mongodb-mms-automation"
/usr/bin/mkdir -p /var/run/mongodb-mms-automation
/usr/bin/chown -R mongod:mongod /var/run/mongodb-mms-automation
echo "Starting automation agent..."
su -s "/bin/bash" -c "/opt/mongodb-mms-automation/bin/mongodb-mms-automation-agent \
-f /etc/mongodb-mms/automation-agent.config \
-pidfilepath /var/run/mongodb-mms-automation/mongodb-mms-automation-agent.pid" mongod
echo "MongoDB Ops Manager automation agent started `date`."