2014-03-08 02:34:09 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
2014-03-08 05:32:19 +00:00
|
|
|
source common/ui.sh
|
2014-03-09 22:34:59 +00:00
|
|
|
source common/utils.sh
|
2014-03-08 02:34:09 +00:00
|
|
|
|
2014-03-08 05:32:19 +00:00
|
|
|
info 'Installing extra packages and upgrading'
|
|
|
|
|
|
|
|
debug 'Bringing container up'
|
2014-03-09 22:34:59 +00:00
|
|
|
utils.lxc.start
|
2014-03-08 05:32:19 +00:00
|
|
|
|
2014-03-09 21:40:46 +00:00
|
|
|
# Sleep for a bit so that the container can get an IP
|
2014-03-09 22:34:59 +00:00
|
|
|
log 'Sleeping for 5 seconds...'
|
2014-03-09 21:40:46 +00:00
|
|
|
sleep 5
|
|
|
|
|
2014-03-08 05:32:19 +00:00
|
|
|
# TODO: Support for setting this from outside
|
2014-03-08 13:42:28 +00:00
|
|
|
UBUNTU_PACKAGES=(vim curl wget man-db bash-completion python-software-properties software-properties-common)
|
2014-03-09 22:34:59 +00:00
|
|
|
utils.lxc.attach apt-get update
|
|
|
|
utils.lxc.attach apt-get install ${UBUNTU_PACKAGES[*]} -y --force-yes
|
|
|
|
utils.lxc.attach apt-get upgrade -y --force-yes
|
2014-03-08 13:42:28 +00:00
|
|
|
|
2014-03-09 20:21:15 +00:00
|
|
|
# TODO: SEPARATE FILE!
|
|
|
|
# Ensure locales are properly set, based on http://askubuntu.com/a/238063
|
2014-03-09 22:34:59 +00:00
|
|
|
utils.lxc.attach locale-gen en_US.UTF-8
|
|
|
|
utils.lxc.attach dpkg-reconfigure locales
|
2014-03-09 20:21:15 +00:00
|
|
|
|
2014-03-09 07:38:36 +00:00
|
|
|
CHEF=${CHEF:-0}
|
|
|
|
PUPPET=${PUPPET:-0}
|
|
|
|
SALT=${SALT:-0}
|
|
|
|
BABUSHKA=${BABUSHKA:-0}
|
|
|
|
|
|
|
|
if [ $CHEF = 1 ]; then
|
2014-03-09 20:19:57 +00:00
|
|
|
if $(lxc-attach -n ${CONTAINER} -- which chef-solo &>/dev/null); then
|
|
|
|
log "Chef has been installed on container, skipping"
|
|
|
|
else
|
|
|
|
log "Installing Chef"
|
|
|
|
cat > ${ROOTFS}/tmp/install-chef.sh << EOF
|
2014-03-09 07:38:36 +00:00
|
|
|
#!/bin/sh
|
|
|
|
curl -L https://www.opscode.com/chef/install.sh -k | sudo bash
|
|
|
|
EOF
|
2014-03-09 20:19:57 +00:00
|
|
|
chmod +x ${ROOTFS}/tmp/install-chef.sh
|
2014-03-09 22:34:59 +00:00
|
|
|
utils.lxc.attach /tmp/install-chef.sh
|
2014-03-09 20:19:57 +00:00
|
|
|
fi
|
2014-03-09 07:38:36 +00:00
|
|
|
else
|
|
|
|
log "Skipping Chef installation"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $PUPPET = 1 ]; then
|
2014-03-09 20:19:57 +00:00
|
|
|
if $(lxc-attach -n ${CONTAINER} -- which puppet &>/dev/null); then
|
|
|
|
log "Puppet has been installed on container, skipping"
|
2014-03-09 20:20:55 +00:00
|
|
|
elif [ ${RELEASE} = 'trusty' ]; then
|
|
|
|
warn "Puppet can't be installed on Ubuntu Trusty 14.04, skipping"
|
2014-03-09 20:19:57 +00:00
|
|
|
else
|
|
|
|
log "Installing Puppet"
|
2014-03-09 23:20:37 +00:00
|
|
|
wget http://apt.puppetlabs.com/puppetlabs-release-stable.deb -O "${ROOTFS}/tmp/puppetlabs-release-stable.deb" &>>${LOG}
|
2014-03-09 22:34:59 +00:00
|
|
|
utils.lxc.attach dpkg -i "/tmp/puppetlabs-release-stable.deb"
|
|
|
|
utils.lxc.attach apt-get update
|
|
|
|
utils.lxc.attach apt-get install puppet -y --force-yes
|
2014-03-09 20:19:57 +00:00
|
|
|
fi
|
2014-03-09 07:38:36 +00:00
|
|
|
else
|
|
|
|
log "Skipping Puppet installation"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $SALT = 1 ]; then
|
2014-03-09 20:55:00 +00:00
|
|
|
if $(lxc-attach -n ${CONTAINER} -- which salt-minion &>/dev/null); then
|
|
|
|
log "Salt has been installed on container, skipping"
|
2014-03-09 22:55:50 +00:00
|
|
|
elif [ ${RELEASE} = 'raring' ]; then
|
|
|
|
warn "Puppet can't be installed on Ubuntu Raring 13.04, skipping"
|
2014-03-09 20:55:00 +00:00
|
|
|
else
|
2014-03-09 22:34:59 +00:00
|
|
|
utils.lxc.attach apt-add-repository -y ppa:saltstack/salt
|
|
|
|
utils.lxc.attach apt-get update
|
|
|
|
utils.lxc.attach apt-get install salt-minion -y --force-yes
|
2014-03-09 20:55:00 +00:00
|
|
|
fi
|
2014-03-09 07:38:36 +00:00
|
|
|
else
|
|
|
|
log "Skipping Salt installation"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $BABUSHKA = 1 ]; then
|
2014-03-09 20:55:00 +00:00
|
|
|
if $(lxc-attach -n ${CONTAINER} -- which babushka &>/dev/null); then
|
|
|
|
log "Babushka has been installed on container, skipping"
|
2014-03-09 22:34:59 +00:00
|
|
|
elif [ ${RELEASE} = 'trusty' ]; then
|
|
|
|
warn "Babushka can't be installed on Ubuntu Trusty 14.04, skipping"
|
2014-03-09 20:55:00 +00:00
|
|
|
else
|
|
|
|
log "Installing Babushka"
|
|
|
|
cat > $ROOTFS/tmp/install-babushka.sh << EOF
|
2014-03-09 07:38:36 +00:00
|
|
|
#!/bin/sh
|
|
|
|
curl https://babushka.me/up | sudo bash
|
|
|
|
EOF
|
2014-03-09 20:55:00 +00:00
|
|
|
chmod +x $ROOTFS/tmp/install-babushka.sh
|
2014-03-09 22:34:59 +00:00
|
|
|
utils.lxc.attach /tmp/install-babushka.sh
|
2014-03-09 20:55:00 +00:00
|
|
|
fi
|
2014-03-09 07:38:36 +00:00
|
|
|
else
|
|
|
|
log "Skipping Babushka installation"
|
|
|
|
fi
|