I'm a really bad blogger. First, I never write. Secondly, I never write about new stuffs. I have my reason and to be honest, I've seen too many very good article so I had to realise, it's not going to be a tech blog. I'm really curious about how my coming MacBook affects to my reading habit. I've got a lot of hope in it. And another big news for me. I'll be a proud cat holder? Call me crazy but she will be my first child. (Besides that if her teacher says she is the smartest in the class - I won't believe it:) Anyway. To restart this stuff I intend to share a small Drupal site generator script with you.
What is the problem?
I'm a Drupal developer. I need to test modules before using it on production sites. I need to try out a lot of things. And the best for doing that is a Drupal sandbox. But it takes 1 or 2 minutes to create one. (At least for me.) ((It should be a Drupal install contest - yeah:))
Create a sandbox once and pre-populate it when needs a new one.
- Download the latest Drupal install: http://drupal.org/
- Install it in a directory called: drupal_sandbox
- Install all the modules you want by default (contrib ones as well)
- Use the database name of: drupal_sandbox in the settings.php
- Tar the drupal_sandbox directory: tar -cvzf drupal_sandbox.tar.gz drupal_sandbox
- Create an sql dump: mysqldump -u YOURUSER --password=YOURPASS drupal_sandbox > drupal_sandbox.sql
# Directory where the tar.gz and sql file lies
# Base file name for the tar.gz and sql files
# Your web root
# Your MySQL user
tar -xvzf $package_dir/$package_name.tar.gz
mv $package_name $1
mv settings.php settings.php.bckup
sed "s/$package_name/$1/g" settings.php.bckup > settings.php
mysql -u $mysql_user --password=$mysql_pwd -e "create database $1"
mysql -u $mysql_user --password=$mysql_pwd $1 < $package_dir/$package_name.sql
Call the script with a parameter (the name of the new drupal site (directory & sql))
sh ./drupal_creator.sh drupal_site_for_testing
Thats it. I hope it works for you. On my environment its fine.