initial commit of a *whole bunch* of old Egressive shell scripts, used to make many people redundant.
This commit is contained in:
commit
43e0f5b59e
329 changed files with 31937 additions and 0 deletions
110
egdrupalhelpers/egdrupalmovesite
Executable file
110
egdrupalhelpers/egdrupalmovesite
Executable file
|
@ -0,0 +1,110 @@
|
|||
#!/bin/bash
|
||||
|
||||
PLATFORMDIR=/home/drupal/core
|
||||
|
||||
usage() {
|
||||
cat <<EOT
|
||||
Usage: `basename $0` servername oldplatform newplatform
|
||||
|
||||
Migrate drupal site servername from oldplatform to newplatform.
|
||||
|
||||
EXAMPLE
|
||||
|
||||
`basename $0` www.mysite.com drupal-6.15 drupal-6.16
|
||||
|
||||
EOT
|
||||
}
|
||||
|
||||
if [ $# -ne 3 ] ; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
servername=$1
|
||||
currentplatform=$2
|
||||
newplatform=$3
|
||||
|
||||
platform_dir() {
|
||||
echo "$PLATFORMDIR/$1"
|
||||
}
|
||||
|
||||
platform_exists() {
|
||||
platform=$1
|
||||
|
||||
if [ -d "`platform_dir $platform`" ] ; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
site_dir() {
|
||||
echo "`platform_dir $2`/sites/$1"
|
||||
}
|
||||
|
||||
site_exists() {
|
||||
site=$1
|
||||
platform=$2
|
||||
|
||||
if [ -z "$platform" ] || [ -z "$site" ] ; then
|
||||
echo "Argument error: site_exists '$platform' '$site'" >&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
|
Loading…
Add table
Add a link
Reference in a new issue