Drupal CVS Checkout Script

The following script will check out a contrib module or core from Drupal CVS and archive it in case you need to revert in future

Usage:

  • ./cvs.sh drupal #checks out drupal HEAD (branch defaults to HEAD
  • ./cvs.sh drupal HEAD /var/www/drupal7 #checks out drupal HEAD into a specific directory
  • ./cvs.sh xmlsitemap DRUPAL-5 #checks out drupal 5 branch
  • ./cvs.sh xmlsitemap DRUPAL-5 /var/www/modules5 #checks out drupal 5 branch and overrides the default directory

Note that if you are checking out a module, rather than Drupal core, the name of the module will be appended to the path where it is to be put. Also note that this script assumes that the Drupal core tree can be deleted, i.e. the sites directory within the tree is not used. I would strongly recommend that the actual website be in a different directory and symlink into the drupal tree, for easy updating. For information on how to do this, look here

drupalpath.sh - Include file for default paths

#Paths to Drupal core files and contrib modules
#Modify the next three lines to suit your configuration
drupaldir=/var/www/drupal
targetdir=/var/www/modules
archivedir=/var/www/archive

cvs.sh - Check Drupal core/modules out of CVS

#!/bin/bash
desc="Update Drupal module from CVS"
usage="$0 <name_of_module>  [version (defaults to HEAD)]  [alternative install path]"
source drupalpath.sh
cvsdir=pserver:anonymous:anonymous@cvs.drupal.org:/cvs/
cvsfolder=drupal-contrib
cvstarget=contributions/modules/   #for themes, this has to be changed to contributions/themes

if [ $# -lt 1 ]; then
  if [ "$1" != "--help" ]; then
    echo "  ** wrong number of arguments supplied **"
  fi
  echo " " $desc
  echo "  Usage:" $usage
  exit
fi
if [ -z "$2" ];then              # default version to HEAD
  version="HEAD"
else
  version=$2
fi
if [ "$1" == "drupal" ]; then
  cvsfolder=drupal
  cvstarget=
  targetdir=$drupaldir
fi
if [ -n "$3" ]; then            # alternative install directory
  targetdir=$3
fi
if [ "$1" != "drupal" ]; then
  targetdir=$targetdir/$1
fi

mkdir temp_cvs
tempcvs=temp_cvs/$1
echo Installing $1 version: $version into: $targetdir
cvs -z6 -Q -d:$cvsdir$cvsfolder checkout -r $version -d $tempcvs $cvstarget$1
return_val=$?
if [ "$return_val" -ne 0 ]; then
  echo "cvs checkout failed for $1 $version"
else
  echo "Archiving to: $archivedir/$1-$version-cvs_$(date +"%Y%m%d").tar.gz"
  tar -zcf $archivedir/$1-$version-cvs_$(date +"%Y%m%d").tar.gz -C temp_cvs $1
  rm -fR $targetdir
  mv $tempcvs $targetdir
fi
rm -fR temp_cvs
AttachmentSize
cvs.txt1.28 KB