From 771dba2c5c8ecbee42d969379838746a1f3a3d34 Mon Sep 17 00:00:00 2001 From: Bryan Roessler Date: Wed, 20 Oct 2021 17:21:06 -0400 Subject: [PATCH] debug to banner --- script-install-banner | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/script-install-banner b/script-install-banner index f4d4eb69..6b92d29e 100644 --- a/script-install-banner +++ b/script-install-banner @@ -5,13 +5,19 @@ is_root +[[ "$#" -gt 0 ]] && DEBUG=on profiledir="/etc/profile.d/" [[ ! -d "$profiledir" ]] && mkdir -p "$profiledir" +if [[ -v DEBUG ]]; then + banner="banner.sh" +else + banner="$profiledir/banner.sh" +fi -cat <<- 'EOF' > "$profiledir/motd.sh" +cat <<- 'EOF' > "$banner" #!/usr/bin/env bash echo -n ' _ _ _ _ _ @@ -24,7 +30,7 @@ echo -n ' EOF # System info -cat <<- 'EOF' >> "$profiledir/motd.sh" +cat <<- 'EOF' >> "$banner" # get load averages IFS=" " read LOAD1 LOAD5 LOAD15 <<<$(cat /proc/loadavg | awk '{ print $1,$2,$3 }') # get free memory @@ -53,7 +59,7 @@ $W Memory......: $G$USED$W used, $G$AVAIL$W avail, $G$TOTAL$W total$W" EOF # Disk usage -cat <<- 'EOF' >> "$profiledir/motd.sh" +cat <<- 'EOF' >> "$banner" # config max_usage=90 bar_width=50 @@ -96,7 +102,7 @@ done EOF # # Disk health -# cat <<- 'EOF' >> "$profiledir/motd.sh" +# cat <<- 'EOF' >> "$banner" # # config # MAX_TEMP=40 # # set column width @@ -168,7 +174,7 @@ EOF # Services -cat <<- 'EOF' >> "$profiledir/motd.sh" +cat <<- 'EOF' >> "$banner" # set column width COLUMNS=3 # colors @@ -208,7 +214,7 @@ EOF # Fail2Ban -cat <<- 'EOF' >> "$profiledir/motd.sh" +cat <<- 'EOF' >> "$banner" # fail2ban-client status to get all jails, takes about ~70ms jails=($(fail2ban-client status | grep "Jail list:" | sed "s/ //g" | awk '{split($2,a,",");for(i in a) print a[i]}')) @@ -228,7 +234,7 @@ printf "\nfail2ban status:\n" printf $out | column -ts $',' | sed -e 's/^/ /' EOF -# cat <<- 'EOF' > "$profiledir/motd.sh" +# cat <<- 'EOF' > "$banner" # #!/usr/bin/env bash # [[ -v NO_MOTD ]] && exit 0 @@ -278,4 +284,10 @@ EOF # EOF +if [[ -v DEBUG ]]; then + bash banner.sh + cat banner.sh + rm banner.sh +fi + exit $? \ No newline at end of file