diff --git a/bin/dps.sh b/bin/dps.sh index 173294ec..29a89fac 100755 --- a/bin/dps.sh +++ b/bin/dps.sh @@ -1,9 +1,18 @@ #/bin/bash -# Show current status of all running containers +# Show current status of T-Pot containers myPARAM="$1" +myCONTAINERS="$(cat /opt/tpot/etc/tpot.yml | grep -v '#' | grep container_name | cut -d: -f2 | sort | tr -d " ")" +myRED="" +myGREEN="" +myBLUE="" +myWHITE="" +myMAGENTA="" + +function fuGETSTATUS { +grc docker ps -f status=running -f status=exited --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" | grep -v "NAME" | sort +} function fuGETSYS { -echo printf "========| System |========\n" printf "%+10s %-20s\n" "Date: " "$(date)" printf "%+10s %-20s\n" "Uptime: " "$(uptime | cut -b 2-)" @@ -13,8 +22,21 @@ echo while true do + myDPS=$(fuGETSTATUS) + myDPSNAMES=$(echo "$myDPS" | awk '{ print $1 }' | sort) fuGETSYS - grc docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" + printf "%-21s %-28s %s\n" "NAME" "STATUS" "PORTS" + if [ "$myDPS" != "" ]; + then + echo "$myDPS" + fi + for i in $myCONTAINERS; do + myAVAIL=$(echo "$myDPSNAMES" | grep -o "$i" | uniq | wc -l) + if [ "$myAVAIL" = "0" ]; + then + printf "%-28s %-28s\n" "$myRED$i" "DOWN$myWHITE" + fi + done if [[ $myPARAM =~ ^([1-9]|[1-9][0-9]|[1-9][0-9][0-9])$ ]]; then sleep "$myPARAM" diff --git a/etc/compose/experimental.yml b/etc/compose/experimental.yml index 92f03a14..39f928cb 100644 --- a/etc/compose/experimental.yml +++ b/etc/compose/experimental.yml @@ -42,7 +42,7 @@ services: # Conpot IEC104 service conpot_IEC104: - container_name: conpot_IEC104 + container_name: conpot_iec104 restart: always stop_signal: SIGINT environment: diff --git a/etc/compose/industrial.yml b/etc/compose/industrial.yml index 953ba4ee..04330c77 100644 --- a/etc/compose/industrial.yml +++ b/etc/compose/industrial.yml @@ -52,7 +52,7 @@ services: # Conpot IEC104 service conpot_IEC104: - container_name: conpot_IEC104 + container_name: conpot_iec104 restart: always stop_signal: SIGINT environment: diff --git a/etc/compose/sensor.yml b/etc/compose/sensor.yml index 06b7af93..390f2bea 100644 --- a/etc/compose/sensor.yml +++ b/etc/compose/sensor.yml @@ -42,7 +42,7 @@ services: # Conpot IEC104 service conpot_IEC104: - container_name: conpot_IEC104 + container_name: conpot_iec104 restart: always stop_signal: SIGINT environment: diff --git a/etc/compose/standard.yml b/etc/compose/standard.yml index 81acf822..21d432a7 100644 --- a/etc/compose/standard.yml +++ b/etc/compose/standard.yml @@ -42,7 +42,7 @@ services: # Conpot IEC104 service conpot_IEC104: - container_name: conpot_IEC104 + container_name: conpot_iec104 restart: always stop_signal: SIGINT environment: