Created
October 21, 2014 23:46
-
-
Save d/fcf4779622326ba224f2 to your computer and use it in GitHub Desktop.
how to make that AMI for Reider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Everything in this script runs as root | |
set -e -u | |
user=tempest | |
user_dir="/home/${user}" | |
echo "--- Installing libyaml manually" | |
pushd /tmp | |
echo "--- Downloading libyaml 0.1.6" | |
wget http://pyyaml.org/download/libyaml/yaml-0.1.6.tar.gz | |
tar -xzvf yaml-0.1.6.tar.gz | |
echo "--- Building libyaml 0.1.6" | |
cd yaml-0.1.6/ | |
./configure | |
make | |
sudo make install | |
sudo ldconfig # Linux specific | |
echo "--- Cleaning up after libyaml" | |
rm -rf yaml* | |
popd | |
echo "--- Treating shellshock" # http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2014-6271 | |
apt-get -y update | |
apt-get -y install --only-upgrade bash | |
echo "--- Installing apt packages" | |
apt-get -y install zlib1g-dev libssl-dev \ | |
ntp \ | |
libreadline6-dev openssh-server \ | |
git-core \ | |
zip unzip curl libcurl4-gnutls-dev \ | |
cdrecord mkisofs \ | |
libxml2-dev libxslt-dev libsqlite3-dev \ | |
mysql-client libmysqlclient-dev \ | |
libpq-dev \ | |
postgresql postgresql-contrib \ | |
echo "--- Configure PostgreSQL users" | |
su - postgres -c 'createuser --superuser tempest-web' | |
su - postgres -c 'psql template1' <<SQLFIX | |
UPDATE pg_database SET datallowconn = TRUE where datname = 'template0'; | |
\c template0 | |
UPDATE pg_database SET datistemplate = FALSE where datname = 'template1'; | |
drop database template1; | |
create database template1 with template = template0 encoding = 'UNICODE' LC_CTYPE = 'en_US.UTF-8' LC_COLLATE = 'C'; | |
UPDATE pg_database SET datistemplate = TRUE where datname = 'template1'; | |
\c template1 | |
UPDATE pg_database SET datallowconn = FALSE where datname = 'template0'; | |
SQLFIX | |
# echo "--- Install Vmware Tools" | |
# https://help.ubuntu.com/community/VMware/Tools | |
# https://github.com/vmw-tmpst/stemcell/blob/fc7fa3bb9cf2c5ffbf4f548933e8d6321d986de2/templates/centosmicro/vmware-tools.sh | |
# apt-get -y install open-vm-tools | |
echo "--- Install Nginx package" | |
echo "deb http://nginx.org/packages/ubuntu/ precise nginx" > /etc/apt/sources.list.d/nginx.list | |
wget -q http://nginx.org/keys/nginx_signing.key -O- | apt-key add - | |
apt-get -y update | |
apt-get -y install nginx-extras # nginx-extras provides third party modules including upload module | |
echo "--- Adding user tempest to admin group" | |
sudo adduser --disabled-password --gecos "" $user | |
# groupadd admin | |
usermod -G admin $user | |
echo "--- Make sure admin group sudoer is not asked for passwords" | |
cat > /etc/sudoers <<SUDOERS | |
Defaults env_reset | |
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin" | |
Defaults env_keep="SSH_AUTH_SOCK" # <----- Addition | |
# Host alias specification | |
# User alias specification | |
# Cmnd alias specification | |
# User privilege specification | |
root ALL=(ALL:ALL) ALL | |
# Members of the admin group may gain root privileges | |
%admin ALL=NOPASSWD: ALL # <----- Addition | |
# Allow members of group sudo to execute any command | |
%sudo ALL=(ALL:ALL) ALL | |
#includedir /etc/sudoers.d | |
SUDOERS | |
ruby_version="2.1.2" | |
echo "--- Installing ruby $ruby_version" | |
( | |
# Bash does not inherit flags! | |
set -e | |
cd /tmp | |
echo "--- Downloading ruby" | |
wget "http://cache.ruby-lang.org/pub/ruby/2.1/ruby-${ruby_version}.tar.gz" | |
tar -xvzf "ruby-${ruby_version}.tar.gz" | |
echo "--- Building ruby" | |
cd "ruby-${ruby_version}/" | |
./configure --prefix=/usr/local --disable-install-doc | |
make | |
make install | |
echo "--- Cleaning ruby" | |
rm -rf "/tmp/ruby-*" | |
echo "--- Updating gem" | |
gem update --system | |
echo "--- Installing bundler/chef/ruby-shadow gems" | |
gem install ruby-shadow bundler --no-ri --no-rdoc | |
# lock at 11.6.2 because 11.8 fails to provision with vagrant 1.3.4/virtualbox 4.2.18/packer 0.3.9 | |
# not really sure which one is the problem, but reverting chef fixed the issue. | |
# gem install chef -v 11.6.2 --no-ri --no-rdoc | |
) | |
echo "--- Empty apt-get cache" | |
apt-get clean |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment