Skip to content

Instantly share code, notes, and snippets.

@jtrupiano
Created June 11, 2009 01:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jtrupiano/127636 to your computer and use it in GitHub Desktop.
Save jtrupiano/127636 to your computer and use it in GitHub Desktop.
Shell Script to Upgrade Ruby Enterprise Edition while Maintaining Directory Naming Sanity
#!/bin/sh
# Author: John Trupiano
# Script to upgrade an REE installation on a hot server and maintain sane directory names
if [ "$(whoami)" != "root" ]; then
echo "You need to be root to run this!"
exit 2
fi
RF_RELEASE=58677
REE_VERSION=20090610
REE=ruby-enterprise-1.8.6-$REE_VERSION
URL=http://rubyforge.org/frs/download.php/$RF_RELEASE/$REE.tar.gz
MOST_RECENT_REE_VERSION=`ls /opt | awk -F"-" '$4 > max && $2 == "enterprise" { max=$4; maxline=$0 }; END { print max }'`
MOST_RECENT_REE=ruby-enterprise-1.8.6-$MOST_RECENT_REE_VERSION
WORKING_DIR=/root/src
echo "Going to update $MOST_RECENT_REE to $REE"
echo "Back up previous release"
cp -R /opt/$MOST_RECENT_REE /opt/$MOST_RECENT_REE.bak
echo "Download new release"
mkdir -p $WORKING_DIR
cd $WORKING_DIR && wget $URL
echo "Untar and install over the previous release for 'upgrade' according to REE manual"
tar xzf $REE.tar.gz
./$REE/installer --auto /opt/$MOST_RECENT_REE
echo "Shuffle folder names to remain sane"
mv /opt/$MOST_RECENT_REE /opt/$REE && mv /opt/$MOST_RECENT_REE.bak /opt/$MOST_RECENT_REE
echo "Actually symlink in the new version of REE"
rm /opt/ruby && ln -s /opt/$REE /opt/ruby
echo "Clean up after ourselves"
rm -f $WORKING_DIR/$REE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment