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