Created
October 29, 2009 16:31
-
-
Save mhorbul/221575 to your computer and use it in GitHub Desktop.
This file contains 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/bash | |
# | |
# Usage: deploy-gem.sh remote-host-name gem-name [branch] | |
# | |
# NOTE: you can provide more than one remote hosts like | |
# deploy-gem.sh rhost1,rhost2,rhost3 gem-name [branch] | |
# | |
# if the branch is provided in the the following format 'master' | |
# the sonian repository git@github.com:sonain/<gem-name>.git will be used | |
# | |
# if the branch name contains the slash like 'repository/whatever-branch', | |
# the following repository will be used | |
# git@github.com:<repository>/<gem-name>.git | |
# | |
# 'branch' is optional, sonian/master will be used by default | |
# | |
REMOTE_HOST=$1 | |
GEM_NAME=$2 | |
GEM_BRANCH=$3 | |
GEM_REPOSITORY="sonian" | |
if [ "$GEM_BRANCH" != "${GEM_BRANCH#*/}" ]; then | |
GEM_REPOSITORY=${GEM_BRANCH%/*} | |
GEM_BRANCH=${GEM_BRANCH#*/} | |
fi | |
# GEM_FILE=`ls ./pkg` | |
# GEM_VERSION=`basename $GEM_FILE .gem | cut -d- -f3`; | |
for host in `echo $REMOTE_HOST | sed -e 's/,/ /g'`; do | |
ssh $host -A "rm -rf /tmp/$GEM_NAME; cd /tmp; \ | |
git clone git@github.com:${GEM_REPOSITORY}/${GEM_NAME}.git; \ | |
cd ${GEM_NAME}; git checkout origin/$GEM_BRANCH; rake gem; \ | |
sudo gem uninstall -a -x -I $GEM_NAME; \ | |
sudo gem install --no-ri --no-rdoc ./pkg/*.gem; \ | |
rm -rf /tmp/$GEM_NAME" | |
if [ "$GEM_NAME" == "sa-backend" ]; then | |
ssh $host "sudo sa-backend stop; \ | |
sudo -u sonian -i sa-backend start" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment