blob: 21197515e6cc67df31c5fecc4324c9835890297c [file] [log] [blame]
Chinthakayala, Sheshashailavas (sc2914)d1569972017-08-28 05:25:46 -09001#!/bin/bash
2tbold=$(tput setf 3)
3bold=$(tput setf 2)
4bold1=$(tput setf 2)
5offbold=$(tput rmso;tput sgr0)
6
7function 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
25function isRunning {
26 echo $(curl -I "$1" 2>/dev/null|head -1|tail -1|awk '{print $2}')
27}
28dirName=$(pwd)
29options=($(ls -l $dirName/releases|grep ^d|awk '{print $NF}'|sort))
30 echo "$(pad RELEASE 15)$(pad URL 30)$(pad Status 10)"
31 echo "$(pad '----' 15)$(pad '---' 30)$(pad '------' 10)"
32 for opt in "${options[@]}"
33 do
34
35 releaseDir="$opt"
36 if [ -e "./releases/${opt}/customSettings.js" ]
37 then
38 pid=$(cat ./releases/$releaseDir/logs/process_pid 2>/dev/null)
39 port=$(cat ./releases/$releaseDir/customSettings.js 2>/dev/null|grep uiPort|sed -e 's/[, ]//g'|cut -d: -f2)
40 resp1=$(isRunning "http://localhost:$port")
41 if [ "$resp1" == "401" ]
42 then
43 echo "$(pad $releaseDir 15)$(pad http://localhost:$port 30)${bold}$(pad running 10)${offbold}"
44 else
45 processId=$(netstat -upltn 2>/dev/null|grep $port|awk '{print $NF}'|sed -e 's%/node-red%%g')
46 if [ "$processId" == "" ]
47 then
48 echo "$(pad $releaseDir 15)$(pad http://localhost:$port 30)${bold}$(pad stopped 10)${offbold}"
49 else
50 echo "$(pad $releaseDir 15)$(pad http://localhost:$port 30)${bold}$(pad running 10)${offbold}"
51 fi
52 fi
53 fi
54 done