2014-01-15 15:09:51 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
2014-01-15 15:29:46 -05:00
|
|
|
# BOOSTRAP SCRIPT
|
|
|
|
# Can take a single param to allow a specific branch to be installed
|
2014-02-19 11:39:15 -05:00
|
|
|
|
2014-04-01 10:54:59 -04:00
|
|
|
usage() { echo "Usage: $0 [-s] [-m MANIFEST_FILE] [BRANCH]" 1>&2; exit 1; }
|
2014-02-19 11:39:15 -05:00
|
|
|
|
2014-04-01 10:54:59 -04:00
|
|
|
while getopts "sm:" o; do
|
2014-02-19 11:39:15 -05:00
|
|
|
case "${o}" in
|
|
|
|
s)
|
|
|
|
SETUP=true
|
|
|
|
;;
|
2014-04-01 10:54:59 -04:00
|
|
|
m)
|
|
|
|
MANIFEST=${OPTARG}
|
|
|
|
;;
|
2014-02-19 11:39:15 -05:00
|
|
|
*)
|
|
|
|
usage
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift $((OPTIND-1))
|
|
|
|
|
2014-01-15 15:29:46 -05:00
|
|
|
BRANCH=$1
|
|
|
|
|
2014-01-15 15:09:51 -05:00
|
|
|
# TO BE RUN AS ROOT
|
|
|
|
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
|
|
|
|
echo "This script must be run as root"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2014-02-19 11:39:15 -05:00
|
|
|
if [ "$SETUP" = true ] ; then
|
2014-03-18 13:05:07 -04:00
|
|
|
# SWAPFILE
|
|
|
|
dd if=/dev/zero of=/swapfile bs=1024 count=512k
|
|
|
|
mkswap /swapfile
|
|
|
|
swapon /swapfile
|
|
|
|
|
2014-02-19 11:39:15 -05:00
|
|
|
# SET TIMESTAMP
|
|
|
|
echo "America/New_York" | tee /etc/timezone
|
|
|
|
dpkg-reconfigure --frontend noninteractive tzdata
|
2014-01-15 15:09:51 -05:00
|
|
|
|
2014-02-19 11:39:15 -05:00
|
|
|
# UPGRADE ALL CURRENT PACKAGES
|
2014-04-01 13:44:47 -04:00
|
|
|
apt-get update && apt-get upgrade -y
|
2014-01-15 15:09:51 -05:00
|
|
|
|
2014-02-19 11:39:15 -05:00
|
|
|
# INSTALL GIT
|
|
|
|
apt-get install git -y
|
2014-01-15 15:14:13 -05:00
|
|
|
|
2014-04-01 13:09:01 -04:00
|
|
|
# INSTALL RUBY 1.9.3 (for rails)
|
|
|
|
apt-get install ruby1.9.3 -y
|
|
|
|
update-alternatives --set ruby /usr/bin/ruby1.9.1
|
|
|
|
update-alternatives --set gem /usr/bin/gem1.9.1
|
|
|
|
|
2014-02-19 11:39:15 -05:00
|
|
|
# INSTALL RUBYGEMS
|
|
|
|
apt-get install rubygems -y
|
2014-01-15 15:09:51 -05:00
|
|
|
|
2014-02-19 11:39:15 -05:00
|
|
|
# INSTALL PUPPET
|
|
|
|
wget http://apt.puppetlabs.com/puppetlabs-release-precise.deb
|
|
|
|
dpkg -i puppetlabs-release-precise.deb
|
|
|
|
apt-get update
|
|
|
|
apt-get install puppet -y
|
2014-01-15 15:09:51 -05:00
|
|
|
|
2014-02-19 11:39:15 -05:00
|
|
|
gem install librarian-puppet
|
|
|
|
fi
|
2014-01-15 15:09:51 -05:00
|
|
|
|
|
|
|
# CLONE PUPPET REPOSITORY
|
|
|
|
cd /tmp
|
2014-01-15 15:29:46 -05:00
|
|
|
rm -rf puppet
|
2014-01-15 15:09:51 -05:00
|
|
|
git clone https://github.com/atomaka/tc362.git puppet
|
2014-01-15 15:32:26 -05:00
|
|
|
cd puppet
|
2014-01-15 15:09:51 -05:00
|
|
|
|
2014-01-15 15:29:46 -05:00
|
|
|
if [ "$BRANCH" != "" ]; then
|
|
|
|
git fetch
|
|
|
|
git checkout $BRANCH
|
|
|
|
fi
|
|
|
|
|
2014-01-15 15:09:51 -05:00
|
|
|
# INSTALL MODULES
|
|
|
|
librarian-puppet install
|
|
|
|
|
|
|
|
# RUN MANIFEST
|
2014-04-01 10:54:59 -04:00
|
|
|
puppet apply manifests/$MANIFEST --modulepath=modules/
|