From b1756cd3f41616545c3b1353baa8837002557602 Mon Sep 17 00:00:00 2001 From: czoczo Date: Fri, 28 Dec 2018 00:48:20 +0100 Subject: [PATCH] changed output text formating, netowrk port info from ss instead of netstat --- statesnap.sh | 64 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 26 deletions(-) diff --git a/statesnap.sh b/statesnap.sh index a87ad36..f1cf810 100755 --- a/statesnap.sh +++ b/statesnap.sh @@ -1,36 +1,48 @@ #!/bin/bash -################ -## CONFIG ## -################ + + +### CONFIG BEGIN ### # Folder to save snaps in SNAP_FOLDER=~/server_states # Array with files to snapshot declare -a CFGBKP=( - "/etc/motd" "/etc/hosts" ) # Bash color definitions -GREEN='\033[00;92m' -BLUE='\033[00;94m' +C1='\033[00;97m' # white +C2='\033[00;95m' # light magenta RST='\033[0m' +### CONFIG END ### + + + # print color message function msg() { - echo -e "$BLUE * $GREEN$1$RST" + echo -e "\n$C2 * $C1$1$RST" } -# colorify diff output -function colorDiff { - awk '/^>/ { print "\033[31m"$0"\033[0m"; } /^]/ { print $0; }' +# print section +function section() { + declare -i X1 X2 X3 WIDTH + WIDTH=60 # total width + X2=${#1}+2 # length of $foo and 2 whitespaces + X1=(WIDTH-X2)/2 # length of first part + X3=$WIDTH-X1-X2 # length of last part + echo -e "$C1" + for ((i=1;i<=$X1;i++)); do echo -n "+"; done + echo -en " $C2$1$C1 +++ (\033[31m missing $C1/\033[32m new$C1 ) " + for ((i=1;i<=$X3;i++)); do echo -n "+"; done + echo -e "$RST" } -# print horizontal line -function HL { - echo -e "$BLUE============================================================================$RST" +# colorify diff output +function colorFilter { + awk '/^>/ { print "\033[31m"$0"\033[0m"; } /^