Skip to content

Instantly share code, notes, and snippets.

@seobyeongky
Last active December 28, 2015 09:39
Show Gist options
  • Save seobyeongky/7479897 to your computer and use it in GitHub Desktop.
Save seobyeongky/7479897 to your computer and use it in GitHub Desktop.
rundb.sh 파일입니다... chmod +x 하고 써야돼요. 그리고 db랑 server 다 test브렌치에 새버전 있어요
RED='\e[0;31m'
YELLOW='\e[1;33m'
CYAN='\e[0;36m'
NC='\e[0m'
if [ $# = 0 ] || [ $1 = "-h" ] || [ $1 = "--help" ]
then
echo -e "${CYAN}usage :${NC}"
echo -e "${YELLOW}1st arg${NC} : container name... ex) autdb_0"
echo -e "${YELLOW}2nd arg${NC} : mongo replica setname... this setname is important. it will be used for cargoship launch name and database name including replica setname... ex) auth"
echo -e "${YELLOW}3rd arg${NC} : my mongo address... this address must be resolvable for every mongo servers in replica set... this script will parse the given address to get the port and run the docker container with the forwarded port ex) 10.20.30.22:27017"
echo -e "${YELLOW}4th arg${NC} : (optional) remote mongo address... you can join the remote replica set... ex) 10.20.16.52:27017"
exit 0
fi
if [ $# -lt 2 ]
then
echo -e "${RED} execption : not enough arguments ${NC}"
exit -1
fi
NAME=$1
SETNAME=$2
MY_ADDR=$3
REMOTE_ADDR=$4
IFS=':' read -a splited_addr <<< "${MY_ADDR}"
PORT="${splited_addr[1]}"
if [ $REMOTE_ADDR ]
then
docker run -link zk:zk -p $PORT:$PORT -e MONGO_SETNAME=$SETNAME -e MY_MONGO_ADDR=$MY_ADDR -e REMOTE_MONGO_ADDR=$REMOTE_ADDR -name $NAME db
else
docker run -link zk:zk -p $PORT:$PORT -e MONGO_SETNAME=$SETNAME -e MY_MONGO_ADDR=$MY_ADDR -name $NAME db
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment