Created
August 6, 2013 01:24
-
-
Save kraigh/6161230 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
SSH_KEY_PATH=`readlink -f ~/.ssh/id_rsa.pub`; | |
KERNEL_VERSION=`uname -v`; # Has distro name in it | |
DEV_REPO_URL='[email protected]:myplanetdigital/savvis.git'; | |
export DEBIAN_FRONTEND=noninteractive # Don't asking questions during install | |
if [[ "$KERNEL_VERSION" == *Ubuntu* ]] | |
then | |
echo "Found Ubuntu kernel."; | |
else | |
echo "This script is Ubuntu specific. You are using $KERNEL_VERSION."; | |
echo "Exiting."; | |
exit 1; | |
fi | |
if [[ -f $SSH_KEY_PATH ]]; | |
then echo "SSH key found in $SSH_KEY_PATH"; # proceed | |
else | |
echo 'No SSH key found. You can generate one with this command:'; | |
echo ' ssh-keygen -t rsa'; | |
exit 1; | |
fi | |
# INSTALL SOME TOOLS | |
echo "Installing basic CLI tools..."; | |
sudo apt-get --yes --force-yes install vim | |
sudo apt-get --yes --force-yes install git | |
sudo apt-get --yes --force-yes install zip | |
sudo apt-get --yes --force-yes install curl | |
# INSTALL LAMP STACK | |
echo "Installing LAMP stack..."; | |
sudo debconf-set-selections <<< 'mysql-server-5.5 mysql-server/root_password password svvs1234' | |
sudo debconf-set-selections <<< 'mysql-server-5.5 mysql-server/root_password_again password svvs1234' | |
sudo apt-get --yes --force-yes install mysql-server | |
sudo apt-get --yes --force-yes install mysql-client | |
sudo apt-get --yes --force-yes install apache2 | |
sudo apt-get --yes --force-yes install php5 php5-curl php5-gd memcached php5-memcache php5-mcrypt php5-mysql php5-cli php5-xdebug | |
# INSTALL PEAR, DRUSH, ETC | |
echo "Installing PEAR, drush, etc..."; | |
sudo apt-get install php-pear | |
sudo pear install -s Console_Table | |
sudo pear channel-discover pear.drush.org | |
sudo pear install -s drush/drush | |
# Clone the development repo | |
echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config | |
git ls-remote "$DEV_REPO_URL" &>- | |
if [ "$?" -ne 0 ]; then | |
echo "Unable to read from '$DEV_REPO_URL'." | |
echo "Paste this SSH key into your github account:" | |
cat ~/.ssh/id_rsa.pub; | |
exit 1; | |
fi | |
echo "Cloning git repo into ~/code..."; | |
mkdir ~/code; | |
cd ~/code; | |
git clone $DEV_REPO_URL; | |
# NEED TO REMOVE THE LINE ADDED ABOVE TO ~/.ssh/config | |
echo "Building marketplace..."; | |
cd savvis; | |
bash tmp/scripts/build-dev.sh ./build-savvis.make ~/code/savvisdirect | |
# IF WE'RE DOING MULTIPLE VHOSTS, WE SHOULD CLONE THE DOCROOT HERE | |
cd /var/www; | |
sudo ln -s ~/code/savvisdirect marketplace | |
cat ~/code/savvis/tmp/local-settings/settings.local.php | sed -e 's/%database%/marketplace/' | sed -e 's/%db_user%/root/' | sed -e 's/%db_password%/svvs1234/' | sed -e 's/%host%/localhost/' > /tmp/settings.local.php; | |
sudo cp /tmp/settings.local.php /var/www/marketplace/sites/default/ | |
mysql -u root -p'svvs1234' -e "create database marketplace" | |
# NEED TO IMPORT A SQL DUMP HERE | |
echo "Configuring apache virtualhost..." | |
sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/default.bak | |
cat /etc/apache2/sites-available/default | sed -e 's/\/var\/www/\/var\/www\/marketplace/' > /tmp/default | |
sudo cp /tmp/default /etc/apache2/sites-available/ | |
sudo a2enmod rewrite | |
sudo service apache2 restart | |
mysqldump=`curl -s http://10.187.255.85/dbdumps/ | grep sql | sed 's/<[^>]\+>/ /g' | head -n 1 | sed 's/^ *//g' | awk '{print $1}'` | |
wget http://10.187.255.85/dbdumps/$mysqldump -O /tmp/mysqldump.gz | |
gunzip /tmp/mysqldump.gz | |
mysql -u root -p'svvs1234' -D'marketplace' < /tmp/mysqldump | |
hostline1='127.0.0.1 local.savvisdirect.com' | |
hostline2='127.0.0.1 savvis.local' | |
sudo -- sh -c "echo $hostline1 >> /etc/hosts" | |
sudo -- sh -c "echo $hostline2 >> /etc/hosts" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment