#!/bin/bash
# See peterjolson.com for useage
CLI_MEMORY=192M
APACHE_MEMORY=128M
# Dont change below here
apt-get update
apt-get upgrade
apt-get install build-essential git-core python-software-properties curl nano
# use php 5.2 instead of 5.3 - instructions from the "Install Apache, PHP and MySQL" section on http://jeffbeeman.com/node/117
add-apt-repository ppa:txwikinger/php5.2
wget http://github.com/jrbeeman/drupal-patches/raw/master/ubuntu-10.04-apt-php-prefs.txt -O /etc/apt/preferences.d/php --no-check-certificate
apt-get update
# start aegir manual install guide: http://community.aegirproject.org/installing/manual
apt-get install apache2 php5 php5-cli php5-gd php5-mysql postfix sudo rsync git-core unzip mysql-server
a2enmod rewrite
ln -s /var/aegir/config/apache.conf /etc/apache2/conf.d/aegir.conf
# Changing memory config and commenting out bind in mysql
sed -i "s/memory_limit = .*/memory_limit = ${CLI_MEMORY}/" /etc/php5/cli/php.ini
sed -i "s/memory_limit = .*/memory_limit = ${APACHE_MEMORY}/" /etc/php5/apache2/php.ini
sed -i "s/bind-address.*/# bind-address = 127.0.0.1/" /etc/mysql/my.cnf
# restart mysql
sudo /etc/init.d/mysql restart
#add aegir_root user to mysql
echo "Please enter your root mysql password: "
OLDMODES=`stty -g`
stty -echo
read MYSQL_ROOT
stty $OLDMODES
echo "Enter what you WANT your aegir_root mysql password to be: "
stty -echo
read MYSQL_AEGIRROOT
stty $OLDMODES
echo "Please enter master aegir servers ip address: "
read AEGIRIP
mysql -p$MYSQL_ROOT -uroot <<< 'CREATE USER "aegir_root"@'$AEGIRIP' IDENTIFIED BY "'$MYSQL_AEGIRROOT'";'
mysql -p$MYSQL_ROOT -uroot <<< 'CREATE USER "aegir_root"@"localhost" IDENTIFIED BY "'$MYSQL_AEGIRROOT'";'
mysql -p$MYSQL_ROOT -uroot <<< 'GRANT ALL PRIVILEGES ON *.* TO "aegir_root"@'$AEGIRIP' WITH GRANT OPTION;'
mysql -p$MYSQL_ROOT -uroot <<< 'GRANT ALL PRIVILEGES ON *.* TO "aegir_root"@"localhost" WITH GRANT OPTION;'
# add aegir user to the system, set bash as schell,
# use ubuntu's profile and bash for pretty console colors
# create ssh dir in aegir home
adduser --system --group --home /var/aegir aegir
adduser aegir www-data
chsh -s /bin/bash aegir
cp /home/ubuntu/.bashrc /var/aegir/
cp /home/ubuntu/.profile /var/aegir/
mkdir /var/aegir/.ssh
# add aegir user to sudoers
if [ -e /etc/sudoers.tmp -o "$(pidof visudo)" ]; then
echo "/etc/sudoers busy, try again later"
exit 1
fi
cp /etc/sudoers /etc/sudoers.bak
cp /etc/sudoers /etc/sudoers.tmp
chmod 0640 /etc/sudoers.tmp
echo "aegir ALL=NOPASSWD: /usr/sbin/apache2ctl" >> /etc/sudoers.tmp
chmod 0440 /etc/sudoers.tmp
mv /etc/sudoers.tmp /etc/sudoers
# install drush because its awesome
wget http://ftp.drupal.org/files/projects/drush-7.x-4.4.tar.gz
mv drush-7.x-4.4.tar.gz /var/aegir
cd /var/aegir
tar zxvf /var/aegir/drush-7.x-4.4.tar.gz
rm /var/aegir/drush-7.x-4.4.tar.gz
chmod u+x /var/aegir/drush/drush
ln -s /var/aegir/drush/drush /usr/bin/drush
chown aegir:aegir /var/aegir -R
#install pecl upload progress
apt-get install php5-dev php-pear
pecl install uploadprogress
echo "extension=uploadprogress.so" >> /etc/php5/apache2/php.ini
echo " "
echo " "
echo "Finished, but you need to edit your hosts file with: nano /etc/hosts"
echo "Also, if your running this on amazon ec2 you need to edit rc.local: nano /etc/rc.local"
echo "After doing the above 2 items, reboot: sudo reboot"
echo "p.s. don't forget to copy your ssh key from your master aegir server to /var/aegir/.ssh"
exit 0