-
-
Save tmilewski/382881 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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