Last active
August 29, 2015 13:56
-
-
Save hoegertn/9296926 to your computer and use it in GitHub Desktop.
Install CloudConductor
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 | |
# USERDATA | |
# $BUCKET=s3 bucket | |
yum -y update | |
# EPEL repo | |
rpm -ivh http://ftp.tu-chemnitz.de/pub/linux/fedora-epel/6/i386/epel-release-6-8.noarch.rpm | |
yum -y clean all | |
yum -y update | |
yum -y install bash-completion vim wget python-magic | |
# Security | |
chkconfig iptables off | |
chkconfig ip6tables off | |
service iptables stop | |
service ip6tables stop | |
echo "SELINUX=disabled" > /etc/sysconfig/selinux | |
# Install AWS CLI | |
yum -y install python-pip | |
pip install awscli | |
# Local env | |
cat > /root/env.sh << "EOF" | |
#!/bin/bash | |
BASE=http://169.254.169.254/latest/meta-data/ | |
export INSTANCE_ID=`curl $BASE/instance-id` | |
export INSTANCE_TYPE=`curl $BASE/instance-type` | |
export AMI_ID=`curl $BASE/ami-id` | |
export PUBLIC_HOSTNAME=`curl $BASE/public-hostname` | |
export AZ_INFO=`curl $BASE/placement/availability-zone` | |
USER_DATA=`curl -f http://169.254.169.254/latest/user-data | tr -d '\r'` | |
IFS=$'\n'; | |
for line in $USER_DATA; | |
do | |
export $line; | |
done; | |
unset IFS; | |
EOF | |
# Install and configure local PostgreSQL | |
rpm -ivh http://yum.postgresql.org/9.2/redhat/rhel-6-x86_64/pgdg-centos92-9.2-6.noarch.rpm | |
yum install -y postgresql92-libs postgresql92 postgresql92-server | |
service postgresql-9.2 initdb | |
service postgresql-9.2 start | |
su -l -c "echo CREATE DATABASE cloudconductor | psql -f -" postgres | |
su -l -c "echo ALTER user postgres WITH PASSWORD \'password\' | psql -f -" postgres | |
service postgresql-9.2 stop | |
echo "*:*:*:postgres:password" > /var/lib/pgsql/.pgpass | |
chown postgres:postgres /var/lib/pgsql/.pgpass | |
chmod 600 /var/lib/pgsql/.pgpass | |
cat > /var/lib/pgsql/9.2/data/pg_hba.conf << "EOF" | |
# TYPE DATABASE USER ADDRESS METHOD | |
# "local" is for Unix domain socket connections only | |
local all all md5 | |
# IPv4 local connections: | |
host all all 127.0.0.1/32 md5 | |
# IPv6 local connections: | |
host all all ::1/128 md5 | |
EOF | |
service postgresql-9.2 start | |
chkconfig postgresql-9.2 on | |
# Install java | |
wget --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" "http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-linux-x64.rpm" -O /root/jdk-7u51-linux-x64.rpm --no-check-certificate | |
rpm -Uvh /root/jdk-7u51-linux-x64.rpm | |
rm -rf /root/jdk-7u51-linux-x64.rpm | |
# Add CloudConductor repo and install server | |
wget -O /etc/yum.repos.d/cloudconductor.repo http://yum.cloudconductor.net/cloudconductor.repo | |
yum -y clean all | |
yum -y install cloudconductor | |
service cloudconductor start | |
# Repo tools | |
yum -y install createrepo yum-utils | |
# Sync bucket to /opt/cloudconductor/static/yum and update CloudConductor | |
mkdir -p /opt/cloudconductor/static/yum | |
cat > /root/yum.sh << "EOF" | |
#!/bin/bash | |
. /root/env.sh | |
aws s3 sync --delete s3://$BUCKET /opt/cloudconductor/static/yum | |
/opt/cloudconductor/helper/create.sh | |
EOF | |
chmod 700 /root/yum.sh | |
cat > /etc/cron.d/cloudconductor-repo << "EOF" | |
*/5 * * * * root /root/yum.sh > /dev/null | |
EOF | |
# drop local ssh-keys and activate auto-load | |
touch /root/firstrun | |
rm -f /root/.ssh/authorized_keys | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment