debug to banner
This commit is contained in:
@@ -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 $?
|
||||
Reference in New Issue
Block a user