blob: d23c301cc97495a5c6a208427bfd0ef4d119a8eb [file] [log] [blame]
yoshi28bac132014-01-22 11:00:17 -08001#!/bin/bash
2
Naoki Shiota4e463182014-03-21 15:13:24 -07003echo
4echo "========================================================================"
5echo "[WARNING] This script is deprecated. Use \"\$ ./onos.sh rc-coord\" instead."
6echo "========================================================================"
7echo
yoshi28bac132014-01-22 11:00:17 -08008
yoshi28bac132014-01-22 11:00:17 -08009# Set paths
10ONOS_HOME=`dirname $0`
11RAMCLOUD_DIR=${HOME}/ramcloud
Bob Lantz63bbe4c2014-02-06 19:29:55 -080012LOGDIR=${ONOS_LOGDIR:-${ONOS_HOME}/onos-logs}
yoshif2806402014-01-23 09:28:39 -080013RAMCLOUD_LOG=${LOGDIR}/ramcloud.coordinator.`hostname`.log
Jonathan Hartd7241452014-03-20 16:45:35 -070014RAMCLOUD_CONF=${RAMCLOUD_CONF:-${ONOS_HOME}/conf/ramcloud.conf}
15#coordinatorip=`grep coordinatorIp ${ONOS_HOME}/conf/ramcloud.conf | cut -d "=" -f 2,3`
16#coordinatorport=`grep coordinatorPort ${ONOS_HOME}/conf/ramcloud.conf | cut -d "=" -f 2,3`
17
18COORDINATOR_IP=`grep coordinatorIp ${RAMCLOUD_CONF} | cut -d "=" -f 2,3`
19COORDINATOR_PORT=`grep coordinatorPort ${RAMCLOUD_CONF} | cut -d "=" -f 2,3`
20
21#RAMCLOUD_COORDINATOR=`echo $coordinatorip","$coordinatorport`
22RAMCLOUD_COORDINATOR=`echo $COORDINATOR_IP","$COORDINATOR_PORT`
Yuta HIGUCHIa7ec0732014-03-10 16:01:06 -070023RAMCLOUD_BRANCH=${RAMCLOUD_BRANCH:-master}
yoshi28bac132014-01-22 11:00:17 -080024
25function lotate {
26 logfile=$1
27 nr_max=${2:-10}
28 if [ -f $logfile ]; then
29 for i in `seq $(expr $nr_max - 1) -1 1`; do
30 if [ -f ${logfile}.${i} ]; then
31 mv -f ${logfile}.${i} ${logfile}.`expr $i + 1`
32 fi
33 done
34 mv $logfile $logfile.1
35 fi
36}
37
38function start {
39 if [ ! -d ${LOGDIR} ]; then
40 mkdir -p ${LOGDIR}
41 fi
42 echo "rotate log: $log"
43 if [ -f $RAMCLOUD_LOG ]; then
44 lotate $RAMCLOUD_LOG
45 fi
46
47 # Run ramcloud
48 echo "Starting ramcloud coordinator"
Yuta HIGUCHIa7ec0732014-03-10 16:01:06 -070049 $RAMCLOUD_DIR/obj.${RAMCLOUD_BRANCH}/coordinator -L $RAMCLOUD_COORDINATOR > $RAMCLOUD_LOG 2>&1 &
yoshi28bac132014-01-22 11:00:17 -080050}
51
52function stop {
53 # Kill the existing processes
54 capid=`pgrep coordinator | awk '{print $1}'`
55 pids="$capid"
56 for p in ${pids}; do
57 if [ x$p != "x" ]; then
58 kill -KILL $p
Jonathan Hartd7241452014-03-20 16:45:35 -070059 echo "Killed existing process (pid: $p)"
yoshi28bac132014-01-22 11:00:17 -080060 fi
61 done
62}
63
yoshi28bac132014-01-22 11:00:17 -080064case "$1" in
65 start)
Jonathan Hartd7241452014-03-20 16:45:35 -070066 #cp $ONOS_HOME/conf/ramcloud.conf /tmp
yoshi28bac132014-01-22 11:00:17 -080067 stop
68 start
69 ;;
70 stop)
71 stop
72 ;;
yoshi28bac132014-01-22 11:00:17 -080073 status)
Yuta HIGUCHIa7ec0732014-03-10 16:01:06 -070074 n=`pgrep -f obj.${RAMCLOUD_BRANCH}/coordinator | wc -l`
yoshi28bac132014-01-22 11:00:17 -080075 echo "$n ramcloud coordinator is running"
76 ;;
77 *)
78 echo "Usage: $0 {start|stop|restart|status}"
79 exit 1
80esac