Creating Drupal Sites from Makefiles, etc.

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
bramface's picture

We talked about this at last month's meeting at Common Media, and I recently came across it --- haven't played with this, but could be useful.

-Bram

DrupalBox is a template Drupal project that can be used to seed (create) a new Drupal project quickly and easily.

The new project will contain:

A Drupal profile (which can also be based on the OpenAtrium profile or the Drupal Commons profile).
Make files for downloading the Drupal core, all the needed modules, libraries, patches, etc.
Scripts for installing a minimal Ubuntu server with all the packages and configurations needed for running a Drupal application.
Scripts, modules, tools and docs that facilitate the development, including a dev-->test-->live workflow.

Create a new project

A new project is created by renaming files of the template project and doing find/replace in them.

Get a copy of the template project from GitHub:
mkdir /var/chroot
cd /var/chroot/
git clone --branch master https://github.com/dashohoxha/dbox.git
The branch openatrium can be used as well, instead of the master branch.
Rename the project:
dbox/rename-project.sh  # see usage
dbox/rename-project.sh labdoo:myproject lbd:mpr
mv dbox myproject
Initialize a git repository:
cd myproject/
git init .
git add $(git ls-files --others)
git commit -a -m 'My new project.'

Instead of initializing a new repo with git init . you can also copy .git from en existing project, like this:
cp -a ../dbox/.git .
git add $(git ls-files --others)
git rm $(git ls-files --deleted)
git add $(git ls-files --modified)

The script rename-project.sh works by renaming files of the template project and doing find/replace in them. There are two parameters that are used to customize the template project: the project name and the project prefix. In the template project they are represented by labdoo and lbd, which are then replaced in the new project by the new project’s name and prefix.

Why these strange names? Why not use something like example and xmp, or sample and smp, or template and tmp etc.

The first reason is exactly that they are strange names and so there is no risk of collision with other names used in a project. For example xmp or template or tmp maybe are used on the project for something else as well, and replacing them blindly with a new value may break the application.

The second reason is that there is actually a real Drupal project with this name and prefix (labdoo and lbd), and this helps to maintain the template project. Any commit on the real project that improves the scripts or profiles, or that fixes any bugs, can be cherry picked and commited to the template project. It works the other way round as well: any change on the template project can be transfered to the real project in order to be tested.
Install the new project

Installation is done by building a new server from scratch, inside a chroot environment.

Modify and customize the settings:
cp myproject/install/settings.sh myproject/cfg.sh
vim myproject/cfg.sh
Install the project inside a chroot system:
nohup nice myproject/install/chroot.sh myproject/cfg.sh &
tail -f nohup.out
less -r nohup.out

This will install in /var/chroot/ a minimal ubuntu system and everything that is needed for the normal work of the system. It will also make the neccessary common configurations of the system. After installation the system should be rebooted.

The installation script will also create the init script
/etc/init.d/chroot-mpr, which can be used to start and stop the
services inside the chroot:
/etc/init.d/chroot-mpr start
/etc/init.d/chroot-mpr stop

If this is a local copy (installed on a local machine), then add the domain name dev.myproject.org on /etc/hosts:
127.0.0.1    dev.myproject.org  localhost
This way it can be accessed by typing https://dev.myproject.org on the browser location (not https://127.0.0.1 or https://localhost).

Western Massachusetts

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week