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
2
egdrupalhelpers/Makefile.am
Normal file
2
egdrupalhelpers/Makefile.am
Normal file
|
@ -0,0 +1,2 @@
|
|||
dist_bin_SCRIPTS = egdrupalsymlinks egdrupaldeploy egdrupalsvnskel egdrupalmoduleversions egdrupalinit egdrupalmovesite egsubtheme
|
||||
EXTRA_DIST = drupal-platform.map.example
|
1
egdrupalhelpers/drupal-platform.map.example
Normal file
1
egdrupalhelpers/drupal-platform.map.example
Normal file
|
@ -0,0 +1 @@
|
|||
drupal6 /home/malc/drupal/drupal-6.13
|
151
egdrupalhelpers/egdrupaldeploy
Executable file
151
egdrupalhelpers/egdrupaldeploy
Executable file
|
@ -0,0 +1,151 @@
|
|||
#!/bin/bash
|
||||
|
||||
PLATFORMDIR=/home/drupal/core
|
||||
DBHOST=mysql0
|
||||
DEVGROUP=drupaladm
|
||||
VHOSTSVNBASE=http://devel.egressive.com/egressive/egpuppet/trunk/virtualhosts/dev
|
||||
ADDPUPPETCONF=0
|
||||
FIXMISSING=1
|
||||
|
||||
usage() {
|
||||
cat <<EOT
|
||||
|
||||
Usage: `basename $0` [ OPTIONS ] siteuri svnuri platform
|
||||
|
||||
Deploy a Drupal site to the specified docroot.
|
||||
|
||||
OPTIONS
|
||||
|
||||
-h - Show this help
|
||||
-l - List available platforms
|
||||
-d dbhost - Specify an alternative database host (Default: $DBHOST)
|
||||
-u user - Site will be owned by user (Default: $USER)
|
||||
|
||||
EOT
|
||||
}
|
||||
|
||||
[ -f "/etc/egscripts/egdrupaldeploy.conf" ] && . /etc/egscripts/egdrupaldeploy.conf
|
||||
|
||||
while getopts "d:u:hl" OPT ; do
|
||||
case $OPT in
|
||||
d) DBHOST=$OPTARG ;;
|
||||
u) SITEUSER=$OPTARG ;;
|
||||
l) ls -1 $PLATFORMDIR ; exit 0 ;;
|
||||
h) usage ; exit 0 ;;
|
||||
*) usage ; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(($OPTIND - 1))
|
||||
|
||||
if [ $# -ne 3 ] ; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
user=${SITEUSER-$USER}
|
||||
siteuri=$1
|
||||
svnuri=$2
|
||||
platform=$3
|
||||
docroot=$PLATFORMDIR/$platform
|
||||
group=`id -g $user`
|
||||
|
||||
# Do some sanity checks
|
||||
if [ -z "$docroot" ] ; then
|
||||
echo "Err: Cannot find docroot for platform $platform" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d $docroot ] || [ ! -f "$docroot/update.php" ] ; then
|
||||
echo "Err: $docroot does not look like a valid Drupal DocumentRoot" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! id $user > /dev/null ; then
|
||||
echo "Err: User $user does not exist" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! getent group $group ; then
|
||||
echo "Err: Group id $group does not exist" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sitedir=$docroot/sites/$siteuri
|
||||
|
||||
if [ -d "$sitedir" ] ; then
|
||||
echo "$sitedir already exists" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set -e
|
||||
|
||||
# Checkout the site code
|
||||
svn co $svnuri $sitedir
|
||||
|
||||
# Create a database for the user
|
||||
dbname=`echo "${user}__${platform}__${siteuri}" | sed -e 's/\./_/g'`
|
||||
|
||||
ret=`egmakedb -H $DBHOST $user $dbname`
|
||||
eval "$ret"
|
||||
|
||||
# Generate the site settings.php
|
||||
# Default for D6
|
||||
default_settings=$docroot/sites/default/default.settings.php
|
||||
if [ ! -f $default_settings ] ; then
|
||||
# Default for D5
|
||||
default_settings=$docroot/sites/default/settings.php
|
||||
fi
|
||||
|
||||
# Create a drushrc.php
|
||||
cat <<EOT > $sitedir/drushrc.php
|
||||
<?php
|
||||
\$options['site_url'] = '$siteuri';
|
||||
EOT
|
||||
|
||||
if [ ! -f $default_settings ] ; then
|
||||
echo "Unable to find default settings file in $docroot/sites/default/" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
settings=$sitedir/settings.php
|
||||
sed -e "s/^\$db_url.*/\$db_url = 'mysql:\/\/$DBUSER:$DBPASS@$DBHOST\/$DBNAME';/" $default_settings > $settings
|
||||
|
||||
cat >> $settings <<EOT
|
||||
// Include local settings file if present
|
||||
if (file_exists(dirname(__FILE__) .'/settings.local.php')) {
|
||||
require_once(dirname(__FILE__) .'/settings.local.php');
|
||||
}
|
||||
EOT
|
||||
|
||||
mkdir -v $sitedir/files
|
||||
|
||||
# Fix missing module symlinks, if any
|
||||
if [ $FIXMISSING -eq 1 ] && [ -d "$sitedir/modules" ] ; then
|
||||
pushd $sitedir/modules
|
||||
egdrupalsymlinks -m
|
||||
fi
|
||||
|
||||
# Make all site dirs and file readable by the web user
|
||||
egsetdiracls $sitedir
|
||||
# Make files directory writeable by the web user
|
||||
egsetdiracls -w $sitedir/files
|
||||
# Make all site files writeable by the site owner
|
||||
egsetdiracls -w -u $user $sitedir
|
||||
# Make all site files writeable by the site owners primary group
|
||||
egsetdiracls -w -u $group $sitedir
|
||||
# Make all site files writeable by the developer group
|
||||
egsetdiracls -w -g $DEVGROUP $sitedir
|
||||
|
||||
if [ "$ADDPUPPETCONF" -eq 1 ] ; then
|
||||
# Create a virtualhost configuration file
|
||||
tmpfile=`mktemp /tmp/egdrupaldeploy-XXXXXX`
|
||||
cat > $tmpfile <<EOT
|
||||
virtualhost { "$siteuri":
|
||||
documentroot => "$docroot",
|
||||
owner => "$user",
|
||||
}
|
||||
EOT
|
||||
svn import -m "egdrupaldeploy: Auto Puppet vhost conf ($siteuri)" $tmpfile $VHOSTSVNBASE/$siteuri.pp
|
||||
rm -v $tmpfile
|
||||
fi
|
46
egdrupalhelpers/egdrupalinit
Executable file
46
egdrupalhelpers/egdrupalinit
Executable file
|
@ -0,0 +1,46 @@
|
|||
#!/bin/bash
|
||||
|
||||
CORE=${CORE-6.x}
|
||||
DEVGROUP=${DEVGROUP-drupaladm}
|
||||
DIRMODE=${DIRMODE-2775}
|
||||
|
||||
base=${1-/home/drupal}
|
||||
|
||||
if [ $UID -ne 0 ] ; then
|
||||
echo "This script must be run as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Exit on any error
|
||||
set -e
|
||||
|
||||
# Create directories
|
||||
mkdir --mode=$DIRMODE -v $base
|
||||
chgrp -v $DEVGROUP $base
|
||||
|
||||
for dir in core contrib libraries sites ; do
|
||||
if [ -d "$base/$dir" ] ; then
|
||||
echo "Directory $dir already exists ... skipping"
|
||||
continue
|
||||
fi
|
||||
mkdir --mode=$DIRMODE -v $base/$dir
|
||||
chgrp -v $DEVGROUP $base/$dir
|
||||
done
|
||||
|
||||
# Get drush
|
||||
egdrupalsymlinks -c $CORE -b $base -d drush
|
||||
# This is a bit of a hack way to get the drush path
|
||||
drush=`find $base/drush -type f -name 'drush' | sort | tail -n 1`
|
||||
|
||||
# Get core
|
||||
version=`xmlstarlet sel --net --text --template --match "/project/releases/release[position()=1]/version" --value-of . --nl http://updates.drupal.org/release-history/drupal/$CORE`
|
||||
echo "Downloading drupal-$version"
|
||||
pushd $base/core
|
||||
$drush dl drupal-$version
|
||||
|
||||
# Add core version to platform map
|
||||
echo "drupal-$version $base/core/drupal-$version" >> /etc/egscripts/drupal-platform.map
|
||||
|
||||
# Set permissions on sites directory
|
||||
chgrp -v $DEVGROUP $base/core/drupal-$version/sites
|
||||
chmod -v g+ws $base/core/drupal-$version/sites
|
16
egdrupalhelpers/egdrupalmoduleversions
Executable file
16
egdrupalhelpers/egdrupalmoduleversions
Executable file
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ -n "$1" ] ; then
|
||||
dir=$1
|
||||
else
|
||||
dir=$PWD
|
||||
fi
|
||||
|
||||
for module in * ; do
|
||||
if [ ! -f $module/$module.info ] ; then
|
||||
echo "Can't find $module/$module.info" 1>&2
|
||||
continue
|
||||
fi
|
||||
echo -n $module
|
||||
awk -F= '/^version/{version=$2}END{print version}' $module/$module.info | sed -e 's/"//g'
|
||||
done
|
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
|
98
egdrupalhelpers/egdrupalsvnskel
Executable file
98
egdrupalhelpers/egdrupalsvnskel
Executable file
|
@ -0,0 +1,98 @@
|
|||
#!/bin/bash
|
||||
|
||||
SVNBASE=http://devel.egressive.com/egressive/egdrupalsites
|
||||
|
||||
comm=`basename $0`
|
||||
|
||||
usage() {
|
||||
cat <<EOT
|
||||
usage: $comm [OPTIONS] -U svnuri | siteuri core
|
||||
|
||||
Create an SVN skeleton tree for a Drupal site.
|
||||
|
||||
OPTIONS
|
||||
|
||||
-h - Show this help
|
||||
-u - SVN tree will belong to user (Default: $user)
|
||||
-b - Specify alternat SVN base URI (Default: $SVNBASE)
|
||||
-U - Manually specify SVN URI
|
||||
|
||||
Create a Drupal subversion skel at svnuri.
|
||||
|
||||
# Create an automatic SVN URL
|
||||
$comm -u egressive ned.egressive.com 6.x
|
||||
# Creates $svnbase/egressive/ned.egressive.com/6.x/trunk/...
|
||||
|
||||
# Specify a non-standard URI
|
||||
$comm -U svn://svn.server.com/some/path
|
||||
|
||||
EOT
|
||||
}
|
||||
|
||||
while getopts "hu:U:" OPT ; do
|
||||
case $OPT in
|
||||
h) usage; exit 0 ;;
|
||||
u) SITEUSER=$OPTARG ;;
|
||||
b) SVNBASE=$OPTARG ;;
|
||||
U) svnuri=$OPTARG ;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(($OPTIND - 1))
|
||||
|
||||
user=${SITEUSER-$USER}
|
||||
|
||||
if [ -n "$svnuri" ] && [ $# -gt 0 ] ; then
|
||||
echo "-U incompatible with extra arguments"
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $# -gt 0 ] ; then
|
||||
siteuri=$1
|
||||
core=$2
|
||||
if [ -z "$siteuri" ] || [ -z "$core" ] ; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
svnuri="$SVNBASE/$user/$siteuri/$core/trunk"
|
||||
fi
|
||||
|
||||
if [ -z "$svnuri" ] ; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Exit on any error
|
||||
set -e
|
||||
|
||||
# Make a temp directory
|
||||
tmpdir=`mktemp -d /tmp/${comm}-XXXXXXXX`
|
||||
|
||||
# cd into it, retaining previous cwd for later
|
||||
pushd $tmpdir
|
||||
|
||||
# Create the top level directory in subversion
|
||||
svn mkdir --parents -m "$comm: Creating project base directory" $svnuri
|
||||
|
||||
# Checkout the newly created dir
|
||||
svn co $svnuri .
|
||||
|
||||
# Make standard directories
|
||||
mkdir -v modules themes libraries
|
||||
svn add modules themes libraries
|
||||
|
||||
# Set ignore properties for standard files and dirs
|
||||
cat <<EOT > ignoreprops
|
||||
files
|
||||
drushrc.php
|
||||
settings.php
|
||||
EOT
|
||||
svn --file=ignoreprops propset svn:ignore .
|
||||
svn commit -m "$comm: Adding standard Drupal layout directories"
|
||||
|
||||
# Cleanup
|
||||
popd
|
||||
rm -rvf $tmpdir
|
||||
|
||||
echo "SVN skel created at $svnuri"
|
292
egdrupalhelpers/egdrupalsymlinks
Executable file
292
egdrupalhelpers/egdrupalsymlinks
Executable file
|
@ -0,0 +1,292 @@
|
|||
#!/bin/bash
|
||||
|
||||
CORE="6.x"
|
||||
BASE_URL="http://updates.drupal.org/release-history"
|
||||
TARGET_BASE=/home/drupal/contrib
|
||||
CORE_BASE=/home/drupal/core
|
||||
UPDATE_XML_CONF=/etc/egscripts/update-xml.conf
|
||||
|
||||
# Mode of operation
|
||||
LIST=0
|
||||
READ=0
|
||||
FIND=0
|
||||
MISSING=0
|
||||
CONTRIBLIST=0
|
||||
DOWNLOAD=0
|
||||
VERSIONLIST=0
|
||||
AUTODOWNLOAD=0
|
||||
|
||||
usage() {
|
||||
cat <<EOT
|
||||
|
||||
Usage: `basename $0` [ OPTIONS ] module [ version ] | -r
|
||||
|
||||
Create a symlink to a Drupal module in the server wide module directory from
|
||||
the current directory.
|
||||
|
||||
If no specific version is specified, the recommended version for this core
|
||||
release will be symlinked.
|
||||
|
||||
OPTIONS
|
||||
|
||||
-b dir - Specify target base directory. (default: $TARGET_BASE)
|
||||
-c core - Specify the required core compatability. (default: $CORE)
|
||||
-d - Download the specified module to the target base directory.
|
||||
-f - Find links to a module, effectively listing all sites which use
|
||||
the named module. If no version is specified, all versions are
|
||||
listed.
|
||||
-h - Show this help.
|
||||
-l - List available versions for module in the target base directory.
|
||||
-L - List available versions for module at drupal.org or the update
|
||||
source specified by -x or -X.
|
||||
-m - Fix missing. Looks for broken symlinks in the current directory
|
||||
and downloads the missing versions to the target directory.
|
||||
-r - Read modules from stdin. One module per line, with the version
|
||||
number as an optional second parameter on each line. If -d was
|
||||
specified, the modules will be downloaded to the target base
|
||||
directory. Otherwise, they will be symlinked in the current
|
||||
directory.
|
||||
-v - List versions of all modules in current directory in a format
|
||||
suitable for -r mode.
|
||||
-x url - Specify the XML feed URL to check for updates. (default: $BASE_URL)
|
||||
-X repo - Specify a known XML feed URL by short name, see $UPDATE_XML_CONF
|
||||
|
||||
EOT
|
||||
}
|
||||
|
||||
# Returns the base URL for the updates XML feed. If an argument is passed,
|
||||
# will look for an info file in the given directory and see if it has an
|
||||
# overridden update URL. This is used by the feature server.
|
||||
#
|
||||
# Otherwise just returns the default.
|
||||
get_base_url() {
|
||||
module=$1
|
||||
if [ -n "$module" ] && [ -f "$module/$module.info" ] ; then
|
||||
override=`awk -F'"' '/^project status url/{print $2}' $module/$module.info`
|
||||
if [ -n "$override" ] ; then
|
||||
echo $override
|
||||
else
|
||||
echo $BASE_URL
|
||||
fi
|
||||
else
|
||||
echo $BASE_URL
|
||||
fi
|
||||
}
|
||||
|
||||
symlink_module() {
|
||||
module=$1
|
||||
version=$2
|
||||
base_url=`get_base_url $module`
|
||||
|
||||
if [ -z "$version" ] ; then
|
||||
# No specific version given, so just get recommended
|
||||
recommended=`xmlstarlet sel --net --text --template --match "/project/recommended_major" --value-of . --nl $base_url/$module/$CORE`
|
||||
|
||||
if [ -z "$recommended" ] ; then
|
||||
echo "Can't find recommened major version for $module"
|
||||
return
|
||||
fi
|
||||
|
||||
# This will grab the version string of the first release for the recommended
|
||||
# major version number
|
||||
version=`xmlstarlet sel --net --text --template --match "/project/releases/release[version_major='$recommended'][position()=1]/version" --value-of . --nl $base_url/$module/$CORE`
|
||||
|
||||
if [ -z "$recommended" ] ; then
|
||||
echo "Can't find recommened version for $module major version $recommended"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
target_dir=$TARGET_BASE/$module/$version
|
||||
if [ ! -d $target_dir ] ; then
|
||||
if [ $AUTODOWNLOAD -eq 1 ] ; then
|
||||
get_module $module $version
|
||||
else
|
||||
echo "$target_dir not present."
|
||||
while read -n1 -p "Do you want to fetch $module-$version? (y/n)" answer ; do
|
||||
case $answer in
|
||||
y) echo ; get_module $module $version; break ;;
|
||||
n) echo ; return ;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -e "$module" ] ; then
|
||||
if [ ! -L "$module" ] ; then
|
||||
echo "$module exists and is not a symlink ... skipping"
|
||||
return
|
||||
else
|
||||
link=`readlink $module`
|
||||
if [ "$link" == "$target_dir" ] ; then
|
||||
echo "$module already links to $target_dir ... skipping"
|
||||
return
|
||||
else
|
||||
echo "$module currently links to $link"
|
||||
while read -n1 -p "Do you want to change it to $module-$version? (y/n)" answer ; do
|
||||
case $answer in
|
||||
y) echo ; rm -v $module ; break ;;
|
||||
n) echo ; return ;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
ln -vs $target_dir $module
|
||||
}
|
||||
|
||||
get_module() {
|
||||
module=$1
|
||||
version=$2
|
||||
base_url=`get_base_url $module`
|
||||
|
||||
if [ -z "$version" ] ; then
|
||||
# No specific version given, so just get recommended
|
||||
recommended=`xmlstarlet sel --net --text --template --match "/project/recommended_major" --value-of . --nl $base_url/$module/$CORE`
|
||||
|
||||
if [ -z "$recommended" ] ; then
|
||||
echo "Can't find recommened major version for $module"
|
||||
return
|
||||
fi
|
||||
|
||||
# This will grab the version string of the first release for the recommended
|
||||
# major version number
|
||||
version=`xmlstarlet sel --net --text --template --match "/project/releases/release[version_major='$recommended'][position()=1]/version" --value-of . --nl $base_url/$module/$CORE`
|
||||
|
||||
if [ -z "$recommended" ] ; then
|
||||
echo "Can't find recommened version for $module major version $recommended"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
target_dir=$TARGET_BASE/$module/$version
|
||||
if [ -d $target_dir ] ; then
|
||||
echo "$target_dir already present ... skipping"
|
||||
return
|
||||
fi
|
||||
url=`xmlstarlet sel --net --text --template --match "/project/releases/release[version='$version']/download_link" --value-of . --nl $base_url/$module/$CORE`
|
||||
if [ -z "$url" ] ; then
|
||||
echo "Unable to determine download URL for $module version $version"
|
||||
return
|
||||
fi
|
||||
mkdir -vp $target_dir
|
||||
echo "Downloading $module ($version) to $target_dir"
|
||||
wget --quiet -O - $url | tar -z -x -f - -C $target_dir --strip 1
|
||||
}
|
||||
|
||||
find_update_xml_url() {
|
||||
awk -v shortname="$1" '{if($1 == shortname){print $2;exit}}' $UPDATE_XML_CONF
|
||||
}
|
||||
|
||||
|
||||
while getopts "c:b:x:X:fdlLrhvm" OPT ; do
|
||||
case $OPT in
|
||||
c) CORE=$OPTARG ;;
|
||||
b) TARGET_BASE=$OPTARG ;;
|
||||
x) BASE_URL=$OPTARG ;;
|
||||
X) BASE_URL=`find_update_xml_url $OPTARG` ;;
|
||||
l) LIST=1 ;;
|
||||
L) CONTRIBLIST=1 ;;
|
||||
m) MISSING=1 ; AUTODOWNLOAD=1 ;;
|
||||
r) READ=1 ; AUTODOWNLOAD=1 ;;
|
||||
f) FIND=1 ;;
|
||||
d) DOWNLOAD=1 ;;
|
||||
v) VERSIONLIST=1 ;;
|
||||
h) usage ; exit 0 ;;
|
||||
*) usage ; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(($OPTIND - 1))
|
||||
|
||||
if [ $READ -eq 0 ] && [ $VERSIONLIST -eq 0 ] ; then
|
||||
if [ $# -lt 1 ] && [ $READ -eq 0 ] && [ $MISSING -eq 0 ] ; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
module=$1
|
||||
version=$2
|
||||
|
||||
if [ $(($LIST + $READ + $FIND + $CONTRIBLIST + $VERSIONLIST + $MISSING)) -gt 1 ] ; then
|
||||
echo "Incompatible options used"
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $LIST -eq 1 ] ; then
|
||||
if [ -d "$TARGET_BASE/$module" ] ; then
|
||||
echo "Available versions of $module for core $CORE:"
|
||||
ls $TARGET_BASE/$module
|
||||
exit 0
|
||||
else
|
||||
echo "$module not present in $TARGET_BASE"
|
||||
exit 1
|
||||
fi
|
||||
elif [ $CONTRIBLIST -eq 1 ] ; then
|
||||
echo "Available releases of $module for core $CORE:"
|
||||
xmlstarlet sel --net --text --template --match '/project/releases/release/version' --value-of . --nl $BASE_URL/$module/$CORE
|
||||
exit 0
|
||||
elif [ $READ -eq 1 ] ; then
|
||||
if [ $DOWNLOAD -eq 1 ] ; then
|
||||
while read module version ; do
|
||||
get_module $module $version
|
||||
done
|
||||
else
|
||||
while read module version ; do
|
||||
symlink_module $module $version
|
||||
done
|
||||
fi
|
||||
exit 0
|
||||
elif [ $FIND -eq 1 ] ; then
|
||||
if [ -z "$version" ] ; then
|
||||
versions=`ls $TARGET_BASE/$module | xargs -n 1 basename`
|
||||
else
|
||||
versions=$version
|
||||
fi
|
||||
for version in $versions ; do
|
||||
find $CORE_BASE -lname $TARGET_BASE/$module/$version
|
||||
done
|
||||
exit 0
|
||||
elif [ $DOWNLOAD -eq 1 ] ; then
|
||||
get_module $module $version
|
||||
elif [ $VERSIONLIST -eq 1 ] ; then
|
||||
for module in * ; do
|
||||
if [ ! -d $module ] ; then
|
||||
echo "$module is not a directory ... skipping" >&2
|
||||
continue
|
||||
fi
|
||||
|
||||
infofile="$module/$module.info"
|
||||
if [ ! -f "$infofile" ] ; then
|
||||
infofile=`find $module/ -name '*.info' | head -n 1`
|
||||
if [ -z "$infofile" ] || [ ! -f "$infofile" ] ; then
|
||||
echo "Can't find a .info file for '$module'" >&2
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
echo -n $module
|
||||
awk -F= '/^version/{version=$2}END{print version}' $infofile | sed -e 's/"//g'
|
||||
done
|
||||
elif [ $MISSING -eq 1 ] ; then
|
||||
for module in * ; do
|
||||
if [ ! -L $module ] ; then
|
||||
continue
|
||||
fi
|
||||
target=`readlink $module`
|
||||
if [ ! -d "$target" ] ; then
|
||||
version=`basename $target`
|
||||
dirname=`dirname $target`
|
||||
module=`basename $dirname`
|
||||
if [ -z "$module" ] || [ -z "$version" ] ; then
|
||||
echo "Can't determine module info from symlink $target" >&2
|
||||
continue
|
||||
fi
|
||||
get_module $module $version
|
||||
fi
|
||||
done
|
||||
else
|
||||
symlink_module $module $version
|
||||
fi
|
122
egdrupalhelpers/egmoduleadd
Executable file
122
egdrupalhelpers/egmoduleadd
Executable file
|
@ -0,0 +1,122 @@
|
|||
#!/bin/bash
|
||||
|
||||
: ${DIALOG=dialog}
|
||||
: ${SVNBASE=http://devel.egressive.com/egressive/drupal_contrib/modules}
|
||||
|
||||
norev=0
|
||||
|
||||
usage() {
|
||||
cat <<EOT
|
||||
|
||||
Usage: $0 [ -h ] [ -r rev ] [ -R ] module
|
||||
|
||||
Add a module to svn:externals in the current working directory
|
||||
|
||||
-h - Show this help
|
||||
-r rev - Pin at revision 'rev'. Default is most recent change.
|
||||
-R - Do not pin at any revision.
|
||||
|
||||
EOT
|
||||
}
|
||||
|
||||
while getopts "hRr:" opt
|
||||
do
|
||||
case ${opt} in
|
||||
h)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
r)
|
||||
revision=${OPTARG}
|
||||
;;
|
||||
R)
|
||||
norev=1
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(( $OPTIND - 1 ))
|
||||
|
||||
if [ `basename $PWD` != 'modules' ]
|
||||
then
|
||||
echo "ERR: You must be in a directory named 'modules' to run this script"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
module=$1
|
||||
|
||||
if [ $# -gt 1 ]
|
||||
then
|
||||
echo "ERR: Too many arguments"
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "${module}" ]
|
||||
then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set -e
|
||||
|
||||
mod_dir=${SVNBASE}/${module}
|
||||
|
||||
for branch in `svn list ${mod_dir}`
|
||||
do
|
||||
choices="${choices} ${branch} ${branch}"
|
||||
done
|
||||
|
||||
if [ -z "${choices}" ]
|
||||
then
|
||||
echo "ERR: Unable to find any branches under ${mod_dir}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
|
||||
trap "rm -f $tempfile" 0 1 2 5 15
|
||||
|
||||
$DIALOG --clear --title "Select Branch" \
|
||||
--menu "Please select an appropriate branch for your drupal version\n" 0 0 0 \
|
||||
$choices 2> $tempfile
|
||||
|
||||
retval=$?
|
||||
|
||||
choice=`cat $tempfile`
|
||||
|
||||
case $retval in
|
||||
0)
|
||||
echo "'$choice' chosen."
|
||||
;;
|
||||
1)
|
||||
echo "Cancel pressed."
|
||||
exit
|
||||
;;
|
||||
255)
|
||||
echo "ESC pressed."
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
|
||||
mod_dir="${mod_dir}/${choice}"
|
||||
|
||||
if [ -z "${revision}" ]
|
||||
then
|
||||
revision=`svn info ${mod_dir} | awk -F: '/^Last Changed Rev/{print $2}'`
|
||||
fi
|
||||
|
||||
if [ $norev -eq 0 ]
|
||||
then
|
||||
revision_string="-r${revision}"
|
||||
fi
|
||||
|
||||
modline="${module} ${revision_string} ${mod_dir}"
|
||||
|
||||
externals=`(svn propget svn:externals . | sed -e "/^${module} /d" ; echo $modline) | sort`
|
||||
svn propset svn:externals "${externals}" .
|
||||
|
||||
echo "Added ${modline} to svn:externals, run 'svn update'"
|
139
egdrupalhelpers/egsubtheme
Executable file
139
egdrupalhelpers/egsubtheme
Executable file
|
@ -0,0 +1,139 @@
|
|||
#!/bin/bash
|
||||
# this script copies a Zen-based Drupal subtheme into a new, named subtheme
|
||||
# the subtheme can be either a real or a linked directory in the site's themes directory
|
||||
|
||||
# default values
|
||||
DEFAULT_LAYOUT='f'
|
||||
DEFAULT_BASE='egressive_blue'
|
||||
# The working directory
|
||||
DEFAULT_DIR=`pwd`
|
||||
|
||||
usage() {
|
||||
cat <<EOT
|
||||
|
||||
Usage: $0 [OPTIONS] sub_theme_name
|
||||
|
||||
Create a sub theme with a given name from a designated Zen-derived base theme.
|
||||
|
||||
This script should be run in your themes directory, and your base theme
|
||||
|
||||
OPTIONS
|
||||
-b - Specify the base theme in your themes directory on which to base the subtheme (default: $DEFAULT_BASE)
|
||||
-l - Specify desired layout, either 'f' for fixed or 'l' for liquid (or 'fluid') layout. (default: $DEFAULT_LAYOUT)
|
||||
|
||||
EXAMPLE
|
||||
|
||||
The following will create a sub theme called "noodle" based on a theme called "snazzy", using a fluid layout.
|
||||
|
||||
$0 -b snazzy -l f noodle
|
||||
|
||||
EOT
|
||||
}
|
||||
|
||||
while getopts "l" OPT ; do
|
||||
case "${OPT}" in
|
||||
b) BASE=$OPTARG ;;
|
||||
l) LAYOUT=$OPTARG ;;
|
||||
d) DIR=$OPTARG ;;
|
||||
h) usage ; exit 0 ;;
|
||||
*) usage ; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(($OPTIND - 1))
|
||||
|
||||
# grab the unflagged argument from the commandline
|
||||
if [ $# -lt 1 ] ; then
|
||||
echo "You must specify a sub theme name"
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# assign them in the appropriate order
|
||||
NAME=$1
|
||||
|
||||
# determine whether the base theme exists and is valid
|
||||
|
||||
# determine the CSS file to use for fixed or fluid layout
|
||||
if [ -z $LAYOUT ]; then
|
||||
echo "no layout specified using default ($DEFAULT_LAYOUT)"
|
||||
LAYOUT=$DEFAULT_LAYOUT
|
||||
fi
|
||||
|
||||
if [ $LAYOUT = "f" ]; then
|
||||
echo "using fixed layout"
|
||||
CSS="layout-fixed.css"
|
||||
elif [ $LAYOUT = "l" ]; then
|
||||
echo "using fluid layout"
|
||||
CSS="layout-liquid.css"
|
||||
else
|
||||
echo "$LAYOUT is an invalid layout type."
|
||||
exit
|
||||
fi
|
||||
|
||||
# determine the base theme to copy
|
||||
if [ -z $BASE ]; then
|
||||
echo "no base theme specified using default ($DEFAULT_BASE)"
|
||||
BASE=$DEFAULT_BASE
|
||||
fi
|
||||
|
||||
DIR=$DEFAULT_DIR
|
||||
|
||||
# check if theme directory already exists, and if so, warn user
|
||||
if [ -d $DIR/$NAME ] ; then
|
||||
echo "The $NAME directory already exists - please remove or move it if you'd like to create it again."
|
||||
exit
|
||||
fi
|
||||
|
||||
# work out if we're looking at a linked dir or not - supply the real dir as target
|
||||
if [ -L $DIR/$BASE ] ; then
|
||||
# the "L" means, if the base directory is a symbolic link, dereference the link and create a
|
||||
# copy of the *linked* directory here.
|
||||
TARGET=`readlink $DIR/$BASE`
|
||||
echo "using link target $TARGET instead of $DIR/$BASE which is a symbolic link"
|
||||
else
|
||||
TARGET=$DIR/$BASE
|
||||
fi
|
||||
|
||||
|
||||
# check that the target (sub)theme exists
|
||||
if [ -d $TARGET ] ; then
|
||||
echo "copying $BASE theme to $NAME"
|
||||
# is it an SVN managed directory?
|
||||
if [ -d $TARGET/.svn ] ; then
|
||||
echo "$TARGET is managed by Subversion, exporting to create unmanaged subtheme $NAME"
|
||||
svn export $TARGET $NAME
|
||||
else
|
||||
cp -Lr $TARGET $NAME
|
||||
fi
|
||||
else
|
||||
echo "$TARGET doesn't exist..."
|
||||
exit
|
||||
fi
|
||||
|
||||
#
|
||||
# Change the theme name (the line 'name = ...') to the new subtheme name
|
||||
#
|
||||
if [ -f $NAME/$BASE.info ] ; then
|
||||
INFO=$NAME/$BASE.info
|
||||
elif [ -f $NAME/$BASE.info.txt ] ; then
|
||||
INFO=$NAME/$BASE.info.txt
|
||||
else
|
||||
echo "there's no original info file for the $BASE theme."
|
||||
exit
|
||||
fi
|
||||
|
||||
echo "using $INFO as the info file"
|
||||
sed 's/'$BASE'/'$NAME'/g' $INFO | sed 's/^\(name *= *\).*/\1'"$NAME"'/g' | sed 's/^\(description *= *\).*/\1'"Zen subtheme ($NAME is derived from $BASE)"'/g' > $NAME/$NAME.info
|
||||
rm $INFO
|
||||
|
||||
#cp $BASE/$CSS $NAME/layout.css
|
||||
#cp $BASE/print.css $NAME/print.css
|
||||
#cp $BASE/html-elements.css $NAME/html-elements.css
|
||||
cp $BASE/$BASE.css $NAME/$NAME.css
|
||||
sed 's/$BASE/'$NAME'/g' $BASE/template.php > $NAME/template.php
|
||||
sed 's/$BASE/'$NAME'/g' $BASE/theme-settings.php > $NAME/theme-settings.php
|
||||
|
||||
echo "Done"
|
||||
|
||||
exit 0
|
Loading…
Add table
Add a link
Reference in a new issue