Skip to content

Instantly share code, notes, and snippets.

@alanivey
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alanivey/28c901bbc2eba87752aa to your computer and use it in GitHub Desktop.
Save alanivey/28c901bbc2eba87752aa to your computer and use it in GitHub Desktop.
Global self-updating Drush on CentOS 6
#!/bin/bash
COMPOSERDIR="/usr/local/bin"
COMPOSERNAME="composer"
DRUSHDIR="/usr/local/share/drush"
# Keep Composer up to date
if [[ ! -x $COMPOSERDIR/$COMPOSERNAME ]]; then
/usr/bin/curl -sS https://getcomposer.org/installer | /usr/bin/php -- --install-dir="$COMPOSERDIR" --filename="$COMPOSERNAME" >/dev/null
elif [[ -f $COMPOSERDIR/$COMPOSERNAME ]]; then
$COMPOSERDIR/$COMPOSERNAME self-update >/dev/null
fi
# Keep Drush up to date in its own directory
export COMPOSER_HOME=$DRUSHDIR
if [[ ! -d $DRUSHDIR ]]; then
$COMPOSERDIR/$COMPOSERNAME global require drush/drush:6.* >/dev/null
else
$COMPOSERDIR/$COMPOSERNAME global update >/dev/null
fi
# Ensure Console-Table exists
if ! ls $DRUSHDIR/vendor/drush/drush/lib/Console_Table-* &>/dev/null; then
curl -0 -s -L http://download.pear.php.net/package/Console_Table-1.1.3.tgz | tar -C $DRUSHDIR/vendor/drush/drush/lib -x -z
fi
[mysql]
comment = mysql
executables = /usr/bin/mysql, /usr/bin/mysqldump
paths = /usr/lib/mysql, /usr/lib64/mysql, /etc/ld.so.conf.d/mysql-i386.conf, /etc/ld.so.conf.d/mysql-x86_64.conf
includesections = netbasics, terminfo
[php]
comment = php
executables = /usr/bin/php
paths = /etc/php.d, /etc/php.ini, /usr/lib/php, /usr/lib64/php, /usr/share/php, /usr/include/php, /usr/share/pear
includesections = netbasics, mysql, terminfo
[drush]
comment = drush
executables = /usr/bin/env, /bin/uname, /bin/basename, /usr/bin/dirname, /usr/bin/which, /usr/bin/readlink, /usr/bin/tput, /usr/bin/stat, /usr/bin/rsync, /usr/bin/tail, /usr/bin/id, /usr/local/bin/composer, /usr/local/share/drush/vendor/bin/drush, /usr/local/share/drush/vendor/bin/drush.bat, /usr/local/share/drush/vendor/bin/drush.complete.sh, /usr/local/share/drush/vendor/bin/drush.php
paths = /usr/share/zoneinfo, /etc/localtime, /usr/local/share/drush, /etc/profile.d/drushcomposer.sh
includesections = php, mysql
if [ -n "$BASH_VERSION" -o -n "$KSH_VERSION" -o -n "$ZSH_VERSION" ]; then
if [ -d /usr/local/share/drush/vendor/bin ]; then
PATH="/usr/local/share/drush/vendor/bin:$PATH"
fi
fi
# Add Composer Drush bin path to the allowed $PATH with sudo
Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/share/drush/vendor/bin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment