Skip to content

Instantly share code, notes, and snippets.

@lsolesen
Last active April 26, 2016 07:23
Show Gist options
  • Save lsolesen/bc644336aa884a675ec0 to your computer and use it in GitHub Desktop.
Save lsolesen/bc644336aa884a675ec0 to your computer and use it in GitHub Desktop.
Setup script for G2 boxes on Codio for running a Drupal install
##########################################################################
#### Script to setup Codio box for Drupal development
##########################################################################
#### Instructions
#### From the Codio Dashboard, create a new Empty template project.
#### Open a Terminal window from the Tools->Terminal window
#### Copy the contents of this file to a file called 'setup.sh' in the root of your machines file system
#### Then run the following command in the Terminal Window
#### bash setup.sh
#### End of Instructions
##########################################################################
echo
echo " STARTING AUTOMATED SETUP OF BOX FOR DRUPAL DEVELOPMENT"
echo
# set colour output = echo -e '\E[1;33;44m'
# remove colour = ; tput sgr0
# See http://www.tldp.org/LDP/abs/html/colorizing.html for colour codes
echo -e '\E[1;33;44m' "Update repositories"; tput sgr0
sudo apt-get update -y
# Install MySQL Server in a Non-Interactive mode. Default root password will be "root"
echo "mysql-server-5.5 mysql-server/root_password password password" | sudo debconf-set-selections
echo "mysql-server-5.5 mysql-server/root_password_again password password" | sudo debconf-set-selections
sudo apt-get -y install mysql-server-5.5
echo -e '\E[1;33;44m' "Install LAMP stack"; tput sgr0
sudo apt-get -y install apache2 mysql-server php5 php5-mysql php5-gd php5-curl
sudo a2enmod rewrite
echo -e '\E[1;33;44m' "Install Ruby and node"; tput sgr0
sudo apt-get install ruby-dev make ruby-full -y
sudo apt-get install nodejs-legacy npm -y
echo -e '\E[1;33;44m' "Setting timezone for PHP"; tput sgr0
sudo echo "date.timezone = Europe/Copenhagen" > /etc/php5/apache2/conf.d/timezone.ini
echo -e '\E[1;33;44m' "Better ressources for PHP"; tput sgr0
sudo sed -i 's/memory_limit = .*/memory_limit = 256M/' /etc/php5/apache2/php.ini
echo -e '\E[1;33;44m' "Start the apache and mysql services"; tput sgr0
sudo service apache2 start
sudo service mysql start
echo -e '\E[1;33;44m' "Install composer"; tput sgr0
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
chmod +x /usr/local/bin/composer
echo -e '\E[1;33;44m' "Install mailcatcher"; tput sgr0
sudo apt-get install sqlite3 -y
gem install mailcatcher
sudo sed -i 's/sendmail_path = .*/sendmail_path = \/usr\/bin\/env catchmail -f [email protected]/' /etc/php5/apache2/php.ini
mailcatcher --ip=0.0.0.0
echo -e '\E[1;33;44m' "Create database 'drupal' with user 'drupal' and password 'password'"; tput sgr0
echo -e '\E[1;33;44m' "WARNING: Those settings are not secure and should be changed"; tput sgr0
mysql -u root -ppassword -e "CREATE DATABASE drupal"
mysql -u root -ppassword -e "CREATE USER 'drupal'@'localhost' IDENTIFIED BY 'password'"
mysql -u root -ppassword -e "GRANT ALL PRIVILEGES ON drupal.* TO 'drupal'@'localhost' IDENTIFIED BY 'password'"
mysql -u root -ppassword -e "FLUSH PRIVILEGES"
echo -e '\E[1;33;44m' "Installing drush"; tput sgr0
cd /home/codio
wget wget http://files.drush.org/drush.phar
chmod +x drush.phar
sudo mv drush.phar /usr/local/bin/drush
drush dl registry_rebuild
echo -e '\E[1;33;44m' "Install phantomjs"; tput sgr0
sudo apt-get install adminer phantomjs -y
echo -e '\E[1;33;44m' "Install zip and unzip"; tput sgr0
sudo apt-get install zip unzip
echo -e '\E[1;33;44m' "Install ungit"; tput sgr0
npm install -g ungit
echo -e '\E[1;33;44m' "Install grunt-cli globally"; tput sgr0
npm install -g grunt-cli
echo -e '\E[1;33;44m' "Preview - Setup Menu - editing .codio file"; tput sgr0
echo '
{
"commands": {
"Reinstall site": "cd ~/workspace && drush si standard --db-url=mysql://drupal:password@localhost/drupal --account-name=admin --account-pass=admin -y",
"PHP Version": "php --version",
"Start PhantomJS": "phantomjs --webdriver=8643",
"Start Ungit": "ungit"
},
"preview": {
"Box URL": "http://{{domain}}:3000/",
"Drupal login": "http://{{domain}}:3000/user",
"Mailcatcher": "http://{{domain}}:1080/",
"Adminer MySQL": "http://{{domain}}:3000/adminer",
"Ungit": "http://{{domain}}:8448/#/"
}
}' > ~/workspace/.codio
echo -e '\E[1;33;44m' "Writing startup.sh to ensure services starts when box restarts"; tput sgr0
echo "service apache2 stop" > ~/startup.sh
echo "service mysql stop" > ~/startup.sh
echo "service apache2 start" >> ~/startup.sh
echo "service mysql start" >> ~/startup.sh
echo "mailcatcher --ip=0.0.0.0" >> ~/startup.sh
echo -e '\E[1;33;44m' "Restart box"; tput sgr0
bash ~/startup.sh
echo -e '\E[1;33;44m' "Box has been setup"; tput sgr0
echo
echo -e '\E[1;33;44m' "You are ready to create your Drupal site by running"; tput sgr0
echo -e '\E[1;33;44m' "cd ~/workspace && drush make build-platform.make ."; tput sgr0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment