Dan Timoney | b217558 | 2017-03-31 17:47:19 -0400 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | tbold=$(tput setf 3) |
| 3 | bold=$(tput setf 2) |
| 4 | bold1=$(tput setf 2) |
| 5 | offbold=$(tput rmso;tput sgr0) |
| 6 | |
| 7 | function pad { |
| 8 | #echo "1 is $1 2 is $2" |
| 9 | if [ "$1" == "" ] |
| 10 | then |
| 11 | $1 = ""; |
| 12 | fi |
| 13 | let count=0 |
| 14 | curr_len=`expr length "$1"` |
| 15 | let space_length=$2-$curr_len |
| 16 | spaces="" |
| 17 | while [ $count -lt $space_length ] |
| 18 | do |
| 19 | spaces="$spaces " |
| 20 | let count=$count+1 |
| 21 | done |
| 22 | echo "$1$spaces" |
| 23 | } |
| 24 | releaseDir="" |
| 25 | if [ "$#" == "1" ] |
| 26 | then |
| 27 | releaseDir="$1" |
| 28 | fi |
| 29 | |
| 30 | if [ -e "releases/${releaseDir}/customSettings.js" ] |
| 31 | then |
| 32 | port=$(cat releases/${releaseDir}/customSettings.js|grep uiPort|sed -e 's/[, ]//g'|cut -d: -f2) |
| 33 | kill $(cat releases/${releaseDir}/logs/process_pid 2>/dev/null) >/dev/null 2>&1 |
| 34 | if [ "$?" != "0" ] |
| 35 | then |
| 36 | #kill only if its a node-red process |
| 37 | processPid=$(netstat -upltn 2>/dev/null|grep -w $port|awk '{print $NF}'|sed -e 's%/node-red%%g') |
| 38 | kill $processPid 2>/dev/null |
| 39 | echo "http://localhost:$port ---- STOPPED" |
| 40 | ./show_status.sh|grep -w "${releaseDir}" |
| 41 | else |
| 42 | echo "http://localhost:$port ---- STOPPED" |
| 43 | ./show_status.sh|grep -w "${releaseDir}" |
| 44 | fi |
| 45 | else |
| 46 | if [ "$releaseDir" != "" ] |
| 47 | then |
| 48 | echo "Release Directory ${releaseDir} not setup."; |
| 49 | else |
| 50 | echo "Usage:$0 releaseDirName" |
| 51 | fi |
| 52 | fi |