#!/bin/bash patch=$1 is_real=false function show_helper { echo "usage: hot-patch.sh patch-file-path [real] servers" echo "eg: hot-patch.sh some-patch.clj real rtm51:11111 rtm52:11111 rtm53:11111" echo "note: without the \"real\" option, only the first server in servers list will be patched" } if [ $# -lt 2 ]; then show_helper exit fi if [ ! -f "$patch" ]; then echo -e "$patch does not exists!\n" show_helper exit fi shift while [ "$1" != "" ]; do case $1 in real ) is_real=true ;; * ) echo "Start patch on $1 ..." cat $patch | lein repl :connect $1 echo "$1 is patched" if [ "$is_real" != true ]; then exit fi esac shift done