debug to banner

This commit is contained in:
2021-10-20 17:21:06 -04:00
parent 1e0b0b0908
commit 771dba2c5c

View File

@@ -5,13 +5,19 @@
is_root is_root
[[ "$#" -gt 0 ]] && DEBUG=on
profiledir="/etc/profile.d/" profiledir="/etc/profile.d/"
[[ ! -d "$profiledir" ]] && mkdir -p "$profiledir" [[ ! -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 #!/usr/bin/env bash
echo -n ' echo -n '
_ _ _ _ _ _ _ _ _ _
@@ -24,7 +30,7 @@ echo -n '
EOF EOF
# System info # System info
cat <<- 'EOF' >> "$profiledir/motd.sh" cat <<- 'EOF' >> "$banner"
# get load averages # get load averages
IFS=" " read LOAD1 LOAD5 LOAD15 <<<$(cat /proc/loadavg | awk '{ print $1,$2,$3 }') IFS=" " read LOAD1 LOAD5 LOAD15 <<<$(cat /proc/loadavg | awk '{ print $1,$2,$3 }')
# get free memory # get free memory
@@ -53,7 +59,7 @@ $W Memory......: $G$USED$W used, $G$AVAIL$W avail, $G$TOTAL$W total$W"
EOF EOF
# Disk usage # Disk usage
cat <<- 'EOF' >> "$profiledir/motd.sh" cat <<- 'EOF' >> "$banner"
# config # config
max_usage=90 max_usage=90
bar_width=50 bar_width=50
@@ -96,7 +102,7 @@ done
EOF EOF
# # Disk health # # Disk health
# cat <<- 'EOF' >> "$profiledir/motd.sh" # cat <<- 'EOF' >> "$banner"
# # config # # config
# MAX_TEMP=40 # MAX_TEMP=40
# # set column width # # set column width
@@ -168,7 +174,7 @@ EOF
# Services # Services
cat <<- 'EOF' >> "$profiledir/motd.sh" cat <<- 'EOF' >> "$banner"
# set column width # set column width
COLUMNS=3 COLUMNS=3
# colors # colors
@@ -208,7 +214,7 @@ EOF
# Fail2Ban # Fail2Ban
cat <<- 'EOF' >> "$profiledir/motd.sh" cat <<- 'EOF' >> "$banner"
# fail2ban-client status to get all jails, takes about ~70ms # 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]}')) 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/^/ /' printf $out | column -ts $',' | sed -e 's/^/ /'
EOF EOF
# cat <<- 'EOF' > "$profiledir/motd.sh" # cat <<- 'EOF' > "$banner"
# #!/usr/bin/env bash # #!/usr/bin/env bash
# [[ -v NO_MOTD ]] && exit 0 # [[ -v NO_MOTD ]] && exit 0
@@ -278,4 +284,10 @@ EOF
# EOF # EOF
if [[ -v DEBUG ]]; then
bash banner.sh
cat banner.sh
rm banner.sh
fi
exit $? exit $?