jtrupiano (owner)

Revisions

gist: 127636 Download_button fork
public
Description:
Shell Script to Upgrade Ruby Enterprise Edition while Maintaining Directory Naming Sanity
Public Clone URL: git://gist.github.com/127636.git
Bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/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