#!/bin/bash PLATFORMDIR=/home/drupal/core usage() { cat <&2 return 1 fi dir=`site_dir $site $platform` if [ -d "$dir" ] && [ ! -L "$dir" ] ; then return 0 else return 1 fi } findlinks() { site=$1 platform=$2 find `platform_dir $platform`/sites -maxdepth 1 -lname "$site/" -or -lname "$site" } if ! platform_exists $currentplatform ; then echo "Platform '$currentplatform' does not exist" exit 1 fi if ! platform_exists $newplatform ; then echo "Platform '$newplatform' does not exist" exit 1 fi if [ "$currentplatform" == "$newplatform" ] ; then echo "$currentplatform and $newplatform are the same platform!" exit 1 fi if ! site_exists $servername $currentplatform ; then echo "$site does not exist under $platform/sites, or is not a directory" exit 1 fi # Check for any symlinks to the current dir links=`findlinks $servername $currentplatform` # Everything checked out, do the work set -e pushd `platform_dir $newplatform`/sites # Create symlinks first for link in $links ; do sudo cp -va $link . done # Move the directory, and symlink from the old location sudo mv -v `site_dir $servername $currentplatform` . && ln -v -s `site_dir $servername $newplatform` `site_dir $servername $currentplatform` pushd `site_dir $servername $newplatform` && drush updatedb popd popd