Author: vines
Date: Wed Jan  2 17:07:36 2013
New Revision: 1427864

URL: http://svn.apache.org/viewvc?rev=1427864&view=rev
Log:
ACCUMULO-921 - fixing unecessary SSH, also making arguments a bit more safe 
(and bourne friendly)


Modified:
    accumulo/branches/1.4/bin/start-server.sh
    accumulo/branches/1.4/bin/stop-server.sh

Modified: accumulo/branches/1.4/bin/start-server.sh
URL: 
http://svn.apache.org/viewvc/accumulo/branches/1.4/bin/start-server.sh?rev=1427864&r1=1427863&r2=1427864&view=diff
==============================================================================
--- accumulo/branches/1.4/bin/start-server.sh (original)
+++ accumulo/branches/1.4/bin/start-server.sh Wed Jan  2 17:07:36 2013
@@ -48,7 +48,7 @@ then
   ip=`python -c 'import socket as s; print s.gethostbyname(s.getfqdn())'`
 fi
 
-if [ $HOST == localhost -o $HOST == "`hostname`" -o $HOST == "$ip" ] 
+if [ "$HOST" = "localhost" -o "$HOST" = "`hostname`" -o "$HOST" = "$ip" ] 
 then
   PID=`ps -ef | egrep ${ACCUMULO_HOME}/.*/accumulo.*.jar | grep "Main 
$SERVICE" | grep -v grep | awk {'print $2'} | head -1`
 else
@@ -57,7 +57,7 @@ fi
 
 if [ -z $PID ]; then
   echo "Starting $LONGNAME on $HOST"
-  if [ $HOST == localhost -o $HOST == "`hostname`" -o $HOST == "$ip" ] 
+  if [ "$HOST" = "localhost" -o "$HOST" = "`hostname`" -o "$HOST" = "$ip" ] 
   then
     ${bin}/accumulo ${SERVICE} --address $1 
>${ACCUMULO_LOG_DIR}/${SERVICE}_${LOGHOST}.out 
2>${ACCUMULO_LOG_DIR}/${SERVICE}_${LOGHOST}.err & 
     MAX_FILES_OPEN=`bash -c 'ulimit -n'`

Modified: accumulo/branches/1.4/bin/stop-server.sh
URL: 
http://svn.apache.org/viewvc/accumulo/branches/1.4/bin/stop-server.sh?rev=1427864&r1=1427863&r2=1427864&view=diff
==============================================================================
--- accumulo/branches/1.4/bin/stop-server.sh (original)
+++ accumulo/branches/1.4/bin/stop-server.sh Wed Jan  2 17:07:36 2013
@@ -21,14 +21,30 @@ bin=`cd "$bin"; pwd`
 
 . "$bin"/config.sh
 
+HOST=$1
+
+IFCONFIG=/sbin/ifconfig
+if [ ! -x $IFCONFIG ]
+then
+   IFCONFIG='/bin/netstat -ie'
+fi
+ip=`$IFCONFIG 2>/dev/null| grep inet[^6] | awk '{print $2}' | sed 's/addr://' 
| grep -v 0.0.0.0 | grep -v 127.0.0.1 | head -n 1`
+if [ $? != 0 ]
+then
+  ip=`python -c 'import socket as s; print s.gethostbyname(s.getfqdn())'`
+fi
 
 # only stop if there's not one already running
-if [ "$1" = "`hostname`" ]; then
+if [ "$HOST" = "localhost" -o "$HOST" = "`hostname`" -o "$HOST" = "$ip" ]; then
        PID=`ps -ef | grep "$ACCUMULO_HOME" | egrep ${2} | grep "Main ${3}" | 
grep -v grep | grep -v ssh | grep -v stop-server.sh | awk {'print \$2'} | head 
-1`
+  if [ ! -z $PID ]; then
+    echo "stopping ${3} on $1";
+    kill -s ${4} ${PID} 2>/dev/null
+  fi;
 else
        PID=`ssh -q -o 'ConnectTimeout 8' $1 "ps -ef | grep \"$ACCUMULO_HOME\" 
|  egrep '${2}' | grep 'Main ${3}' | grep -v grep | grep -v ssh | grep -v 
stop-server.sh" | awk {'print $2'} | head -1`
+  if [ ! -z $PID ]; then
+    echo "stopping ${3} on $1";
+    ssh -q -o 'ConnectTimeout 8' $1 "kill -s ${4} ${PID} 2>/dev/null"
+  fi;
 fi
-if [ ! -z $PID ]; then
-        echo "stopping ${3} on $1";
-        ssh -q -o 'ConnectTimeout 8' $1 "kill -s ${4} ${PID} 2>/dev/null"
-fi;


Reply via email to