Skip to content

Instantly share code, notes, and snippets.

@eos87
Forked from jeanlescure/init.sh
Created June 4, 2014 21:18
Show Gist options
  • Save eos87/cd17aa7c864d654e18fa to your computer and use it in GitHub Desktop.
Save eos87/cd17aa7c864d654e18fa to your computer and use it in GitHub Desktop.
#######################################################################
# Automated Dev Environment Installation for APTrustDPN on Ubuntu 14.04
# Author: Jean M. Lescure
#
# To use:
# *download to home folder
# chmod 777 init.sh
# ./init.sh
#######################################################################
echo -e "\E[0;36m--> 1. Installing rabbitmq ...\E[0m"
sudo apt-get install -y rabbitmq-server
echo -e "\E[0;36m--> -1a. Setting NODENAME=aptrust at /etc/rabbitmq/rabbitmq-env.conf ...\E[0m"
if [ ! -d "/etc/rabbitmq" ]; then
sudo bash -c "mkdir /etc/rabbitmq"
fi
sudo bash -c "echo \"NODENAME=aptrust\" > /etc/rabbitmq/rabbitmq-env.conf"
echo -e "\E[0;36m--> -1b. Enabling rabbitmq_management plugin ...\E[0m"
sudo rabbitmq-plugins enable rabbitmq_management
# <anti-bugs>
# Needed in order to keep other processes from blocking
# the ports 5672 and 15672, so we can download rabbitmqadmin
sudo service rabbitmq-server stop
sudo fuser -k -n tcp 5672
sudo fuser -k -n tcp 15672
sudo service rabbitmq-server start
# </anti-bugs>
echo -e "\E[0;36m--> -1c. Loading rabbitmqadmin ...\E[0m"
rm ~/rabbitmqadmin
wget http://127.0.0.1:15672/cli/rabbitmqadmin
chmod 777 ./rabbitmqadmin
echo -e "\E[0;36m--> -1c. Setting up Queues, Exchange, and Bindings ...\E[0m"
./rabbitmqadmin declare queue name=test durable=true
./rabbitmqadmin declare queue name=local durable=true
./rabbitmqadmin declare exchange name=dpn-control-exchange type=direct
./rabbitmqadmin declare binding source=dpn-control-exchange destination_type="queue" destination=test routing_key=broadcast
./rabbitmqadmin declare binding source=dpn-control-exchange destination_type="queue" destination=local routing_key=aptrust.dpn
echo -e "\E[0;36m--> 2. Installing Python 3.4 ...\E[0m"
sudo apt-get install -y python-software-properties git cowsay
sudo add-apt-repository ppa:fkrull/deadsnakes
sudo apt-get update
sudo apt-get install -y python3.4
echo -e "\E[0;36m--> -2a. Installing pip for Python 3.4 ...\E[0m"
sudo apt-get install -y python3-pip
echo -e "\E[0;36m--> 3. Installing virtualenv and virtualenvwrapper for Python 3.4 ...\E[0m"
sudo pip3 install virtualenv virtualenvwrapper
echo -e "\E[0;36m--> -3a. Adding virtualenvwrapper settings in ~/.bashrc ...\E[0m"
if grep "VIRTUALENVWRAPPER_PYTHON" ~/.bashrc
then
echo -e "\E[0;35m----> Found virtualenvwrapper settings in ~/.bashrc ... skipping this step\E[0m"
else
sudo bash -c "echo \"\" >> ~/.bashrc"
sudo bash -c "echo \"export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3.4\" >> ~/.bashrc"
sudo bash -c "echo \"export WORKON_HOME=~/.virtualenvs\" >> ~/.bashrc"
sudo bash -c "echo \"export PROJECT_HOME=~/dev\" >> ~/.bashrc"
sudo bash -c "echo \"export VIRTUALENVWRAPPER_LOG_DIR=/tmp\" >> ~/.bashrc"
sudo bash -c "echo \"source /usr/local/bin/virtualenvwrapper.sh\" >> ~/.bashrc"
sudo bash -c "echo \"\" >> ~/.bashrc"
fi
echo -e "\E[0;36m--> Done! ...\E[0m\E[0;32m"
cowsay "Remember to run 'source ~/.bashrc' or restart your session before continuing!"
echo -e "\E[0m"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment