2015-06-15 21:39:47 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
MINION_ADMINISTRATOR_EMAIL="april@mozilla.com"
|
|
|
|
MINION_ADMINISTRATOR_NAME="April King"
|
|
|
|
|
2015-09-02 22:20:17 +03:00
|
|
|
# The base directory for large pieces of the install
|
|
|
|
MINION_BASE_DIRECTORY=/opt/minion
|
|
|
|
|
2015-09-10 20:19:46 +03:00
|
|
|
# Install backend only packages
|
|
|
|
apt-get -y install curl \
|
|
|
|
libcurl4-openssl-dev \
|
|
|
|
libffi-dev \
|
|
|
|
mongodb-server \
|
|
|
|
nmap \
|
|
|
|
postfix \
|
|
|
|
rabbitmq-server \
|
|
|
|
stunnel
|
|
|
|
|
|
|
|
# For some reason, it has trouble adding the rabbitmq groups
|
|
|
|
apt-get -y install rabbitmq-server
|
2015-06-15 21:39:47 +03:00
|
|
|
|
2015-09-02 22:20:17 +03:00
|
|
|
# First, source the virtualenv
|
|
|
|
cd ${MINION_BASE_DIRECTORY}
|
|
|
|
source minion-env/bin/activate
|
|
|
|
|
|
|
|
# Next, let's install minion-backend
|
|
|
|
|
|
|
|
# Uncomment this line if you don't have a local working copy on your local system
|
|
|
|
# git clone https://github.com/mozilla/minion-backend.git ${MINION_BASE_DIRECTORY}/minion-backend
|
|
|
|
cd minion-backend
|
2015-06-15 21:39:47 +03:00
|
|
|
python setup.py develop
|
|
|
|
|
2015-09-02 22:20:17 +03:00
|
|
|
# Configure minion-backend (listening on 0.0.0.0:8383, and with no blacklist)
|
2015-06-15 21:39:47 +03:00
|
|
|
mkdir -p /etc/minion
|
2015-09-02 22:20:17 +03:00
|
|
|
mv /tmp/scan.json /etc/minion
|
2015-06-15 21:39:47 +03:00
|
|
|
|
2015-09-02 22:20:17 +03:00
|
|
|
# Install minion-nmap-plugin; comment out `git clone` if working on minion-nmap-plugin locally
|
2015-08-04 01:06:12 +03:00
|
|
|
# via Vagrant synced folder
|
2015-09-02 22:20:17 +03:00
|
|
|
git clone https://github.com/mozilla/minion-nmap-plugin ${MINION_BASE_DIRECTORY}/minion-nmap-plugin
|
|
|
|
cd ${MINION_BASE_DIRECTORY}/minion-nmap-plugin
|
2015-06-16 21:19:33 +03:00
|
|
|
python setup.py install
|
2015-06-15 21:39:47 +03:00
|
|
|
|
2015-09-02 22:20:17 +03:00
|
|
|
# Add the minion init scripts to the system startup scripts
|
|
|
|
cp ${MINION_BASE_DIRECTORY}/minion-backend/scripts/minion-init /etc/init.d/minion
|
|
|
|
chown root:root /etc/init.d/minion
|
|
|
|
chmod 755 /etc/init.d/minion
|
|
|
|
update-rc.d minion defaults 40
|
|
|
|
|
|
|
|
# Setup the minion environment for the minion user
|
|
|
|
echo -e "\n# Minion convenience commands" >> ~minion/.bashrc
|
|
|
|
echo -e "alias miniond=\"supervisord -c ${MINION_BASE_DIRECTORY}/minion-backend/etc/supervisord.conf\"" >> ~minion/.bashrc
|
|
|
|
echo -e "alias minionctl=\"supervisorctl -c ${MINION_BASE_DIRECTORY}/minion-backend/etc/supervisord.conf\"" >> ~minion/.bashrc
|
2015-06-15 21:39:47 +03:00
|
|
|
|
2015-09-10 20:19:46 +03:00
|
|
|
# Start MongoDB
|
|
|
|
service mongodb start
|
|
|
|
sleep 5
|
|
|
|
|
|
|
|
# Start RabbitMQ
|
|
|
|
service rabbitmq-server start
|
|
|
|
sleep 5
|
|
|
|
|
2015-06-15 21:39:47 +03:00
|
|
|
# Start Minion
|
2015-09-02 22:20:17 +03:00
|
|
|
service minion start
|
|
|
|
sleep 30
|
2015-06-15 21:39:47 +03:00
|
|
|
|
|
|
|
# Create the initial administrator and database
|
2015-09-02 22:20:17 +03:00
|
|
|
minion-db-init "$MINION_ADMINISTRATOR_EMAIL" "$MINION_ADMINISTRATOR_NAME" y
|
2015-06-15 23:17:52 +03:00
|
|
|
|
2015-09-10 20:19:46 +03:00
|
|
|
# If we're running in Docker, we start these with CMD
|
2015-06-15 23:17:52 +03:00
|
|
|
if [[ $MINION_DOCKERIZED == "true" ]]; then
|
2015-09-10 20:19:46 +03:00
|
|
|
service minion stop
|
|
|
|
sleep 30
|
|
|
|
service rabbitmq-server stop
|
|
|
|
sleep 5
|
|
|
|
|
|
|
|
# This seems to be broken on Ubuntu 14.04, since it doesn't create the /var/run/mongodb directory
|
|
|
|
# service mongodb stop
|
|
|
|
kill `ps aux | grep mongod | grep -v grep | tr -s ' ' | cut -d ' ' -f 2`
|
2016-02-08 19:25:26 +03:00
|
|
|
fi
|