mirror of
https://github.com/telekom-security/tpotce.git
synced 2025-07-01 04:22:11 +00:00
speed up dps.sh
grc now supports docker, use it to colorize docker ps output without any dependencies to *.yml
This commit is contained in:
parent
e623dbeb4d
commit
c2baf27761
2 changed files with 3 additions and 50 deletions
51
bin/dps.sh
51
bin/dps.sh
|
@ -1,47 +1,9 @@
|
||||||
#/bin/bash
|
#/bin/bash
|
||||||
# Show current status of all running containers
|
# Show current status of all running containers
|
||||||
myPARAM="$1"
|
myPARAM="$1"
|
||||||
myIMAGES="$(cat /opt/tpot/etc/tpot.yml | grep -v '#' | grep container_name | cut -d: -f2)"
|
|
||||||
myRED="[1;31m"
|
|
||||||
myGREEN="[1;32m"
|
|
||||||
myBLUE="[1;34m"
|
|
||||||
myWHITE="[0;0m"
|
|
||||||
myMAGENTA="[1;35m"
|
|
||||||
|
|
||||||
function fuCONTAINERSTATUS {
|
|
||||||
local myNAME="$1"
|
|
||||||
local mySTATUS="$(/usr/bin/docker ps -f name=$myNAME --format "table {{.Status}}" -f status=running -f status=exited | tail -n 1)"
|
|
||||||
myDOWN="$(echo "$mySTATUS" | grep -o -E "(STATUS|NAMES|Exited)")"
|
|
||||||
|
|
||||||
case "$myDOWN" in
|
|
||||||
STATUS)
|
|
||||||
mySTATUS="$myRED"DOWN"$myWHITE"
|
|
||||||
;;
|
|
||||||
NAMES)
|
|
||||||
mySTATUS="$myRED"DOWN"$myWHITE"
|
|
||||||
;;
|
|
||||||
Exited)
|
|
||||||
mySTATUS="$myRED$mySTATUS$myWHITE"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
mySTATUS="$myGREEN$mySTATUS$myWHITE"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
printf "$mySTATUS"
|
|
||||||
}
|
|
||||||
|
|
||||||
function fuCONTAINERPORTS {
|
|
||||||
local myNAME="$1"
|
|
||||||
local myPORTS="$(/usr/bin/docker ps -f name=$myNAME --format "table {{.Ports}}" -f status=running -f status=exited | tail -n 1 | sed s/","/",\n\t\t\t\t\t\t\t"/g)"
|
|
||||||
|
|
||||||
if [ "$myPORTS" != "PORTS" ];
|
|
||||||
then
|
|
||||||
printf "$myBLUE$myPORTS$myWHITE"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function fuGETSYS {
|
function fuGETSYS {
|
||||||
|
echo
|
||||||
printf "========| System |========\n"
|
printf "========| System |========\n"
|
||||||
printf "%+10s %-20s\n" "Date: " "$(date)"
|
printf "%+10s %-20s\n" "Date: " "$(date)"
|
||||||
printf "%+10s %-20s\n" "Uptime: " "$(uptime | cut -b 2-)"
|
printf "%+10s %-20s\n" "Uptime: " "$(uptime | cut -b 2-)"
|
||||||
|
@ -52,16 +14,7 @@ echo
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
fuGETSYS
|
fuGETSYS
|
||||||
printf "%-19s %-36s %s\n" "NAME" "STATUS" "PORTS"
|
grc docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
|
||||||
for i in $myIMAGES; do
|
|
||||||
myNAME="$myMAGENTA$i$myWHITE"
|
|
||||||
printf "%-32s %-49s %s" "$myNAME" "$(fuCONTAINERSTATUS $i)" "$(fuCONTAINERPORTS $i)"
|
|
||||||
echo
|
|
||||||
if [ "$myPARAM" = "vv" ];
|
|
||||||
then
|
|
||||||
/usr/bin/docker exec -t "$i" sh -c "stty rows 50 cols 1000 && /bin/ps aux | egrep -v -E 'awfuwfxwf|/bin/ps'"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if [[ $myPARAM =~ ^([1-9]|[1-9][0-9]|[1-9][0-9][0-9])$ ]];
|
if [[ $myPARAM =~ ^([1-9]|[1-9][0-9]|[1-9][0-9][0-9])$ ]];
|
||||||
then
|
then
|
||||||
sleep "$myPARAM"
|
sleep "$myPARAM"
|
||||||
|
|
|
@ -101,7 +101,7 @@ tasksel tasksel/first multiselect ubuntu-server
|
||||||
########################
|
########################
|
||||||
### Package Installation
|
### Package Installation
|
||||||
########################
|
########################
|
||||||
d-i pkgsel/include string apache2-utils apparmor apt-transport-https aufs-tools bash-completion build-essential ca-certificates cgroupfs-mount curl dialog dnsutils docker.io docker-compose dstat ethtool genisoimage git glances html2text htop ifupdown iptables iw jq libcrack2 libltdl7 lm-sensors man net-tools npm ntp openssh-server openssl prips syslinux psmisc pv python-pip unzip vim wireless-tools wpasupplicant
|
d-i pkgsel/include string apache2-utils apparmor apt-transport-https aufs-tools bash-completion build-essential ca-certificates cgroupfs-mount curl dialog dnsutils docker.io docker-compose dstat ethtool genisoimage git glances grc html2text htop ifupdown iptables iw jq libcrack2 libltdl7 lm-sensors man net-tools npm ntp openssh-server openssl prips syslinux psmisc pv python-pip unzip vim wireless-tools wpasupplicant
|
||||||
|
|
||||||
#################
|
#################
|
||||||
### Update Policy
|
### Update Policy
|
||||||
|
|
Loading…
Reference in a new issue