fix: Correct funky formatting 🎨
All checks were successful
CI / lint (push) Successful in 55s
CI / Molecule Test (almalinux8) (push) Successful in 2m29s
CI / Molecule Test (almalinux9) (push) Successful in 2m40s
CI / release (push) Successful in 20s

This commit is contained in:
2024-04-24 15:30:42 +12:00
parent 6c80c1b07b
commit 352ea54e11

View File

@@ -16,88 +16,88 @@
# #
if getent group "{{ admin_group }}" | grep -qw "$(whoami)"; then if getent group "{{ admin_group }}" | grep -qw "$(whoami)"; then
USER=`/usr/bin/env whoami` USER=`/usr/bin/env whoami`
HOSTNAME=`/usr/bin/env uname -n | /usr/bin/env cut -d. -f1` HOSTNAME=`/usr/bin/env uname -n | /usr/bin/env cut -d. -f1`
IP=`/usr/bin/env ip route get 1 | /usr/bin/env grep -Po '(?<=src.)[\w\d.]+'` IP=`/usr/bin/env ip route get 1 | /usr/bin/env grep -Po '(?<=src.)[\w\d.]+'`
IP6=`/usr/bin/env ip -6 addr | /usr/bin/env awk -F '[ \t]+|/' '$3 == "::1" { next;} $3 ~ /^fe80::/ { next ; } /inet6/ {print $3} '` IP6=`/usr/bin/env ip -6 addr | /usr/bin/env awk -F '[ \t]+|/' '$3 == "::1" { next;} $3 ~ /^fe80::/ { next ; } /inet6/ {print $3} '`
NUM_CPU=`cat /proc/cpuinfo | grep processor | wc -l` NUM_CPU=`cat /proc/cpuinfo | grep processor | wc -l`
#ROOT=`/usr/bin/df / -x fuse.gvfs-fuse-daemon -Ph | /usr/bin/egrep -i 'root|logvol|vda' | awk '{print $4}' | tr -d '\n'` #ROOT=`/usr/bin/df / -x fuse.gvfs-fuse-daemon -Ph | /usr/bin/egrep -i 'root|logvol|vda' | awk '{print $4}' | tr -d '\n'`
#HOME=`/usr/bin/df /home -x fuse.gvfs-fuse-daemon -Ph | grep home | awk '{print $4}' | tr -d '\n'` #HOME=`/usr/bin/df /home -x fuse.gvfs-fuse-daemon -Ph | grep home | awk '{print $4}' | tr -d '\n'`
#BACKUP=`/usr/bin/df -x fuse.gvfs-fuse-daemon -Ph | grep backup | awk '{print $4}' | tr -d '\n'` #BACKUP=`/usr/bin/df -x fuse.gvfs-fuse-daemon -Ph | grep backup | awk '{print $4}' | tr -d '\n'`
FILESYSTEMS=`cat /etc/fstab | grep -v '#' | grep -v 'swap' | grep -v 'proc' | awk '{if(NF>0) {print $2}}'` FILESYSTEMS=`cat /etc/fstab | grep -v '#' | grep -v 'swap' | grep -v 'proc' | awk '{if(NF>0) {print $2}}'`
MEMORY=`/usr/bin/env free -m | /usr/bin/env grep "Mem" | /usr/bin/env awk '{print $2,"-",$3,"-",$4}'` MEMORY=`/usr/bin/env free -m | /usr/bin/env grep "Mem" | /usr/bin/env awk '{print $2,"-",$3,"-",$4}'`
SWAP=`/usr/bin/env free -m | /usr/bin/env grep "Swap" | /usr/bin/env awk '{print $2,"-",$3,"-",$4}'` SWAP=`/usr/bin/env free -m | /usr/bin/env grep "Swap" | /usr/bin/env awk '{print $2,"-",$3,"-",$4}'`
PSA=`/usr/bin/env ps -Afl | /usr/bin/env wc -l` PSA=`/usr/bin/env ps -Afl | /usr/bin/env wc -l`
# time of day # time of day
HOUR=$(/usr/bin/env date +"%H") HOUR=$(/usr/bin/env date +"%H")
if [ $HOUR -lt 12 -a $HOUR -ge 0 ] if [ $HOUR -lt 12 -a $HOUR -ge 0 ]
then TIME="morning" then TIME="morning"
elif [ $HOUR -lt 17 -a $HOUR -ge 12 ] elif [ $HOUR -lt 17 -a $HOUR -ge 12 ]
then TIME="afternoon" then TIME="afternoon"
else else
TIME="evening" TIME="evening"
fi fi
#System uptime #System uptime
uptime=`/usr/bin/env cat /proc/uptime | cut -f1 -d.` uptime=`/usr/bin/env cat /proc/uptime | cut -f1 -d.`
upDays=$((uptime/60/60/24)) upDays=$((uptime/60/60/24))
upHours=$((uptime/60/60%24)) upHours=$((uptime/60/60%24))
upMins=$((uptime/60%60)) upMins=$((uptime/60%60))
upSecs=$((uptime%60)) upSecs=$((uptime%60))
#System load #System load
LOADAVG=`/usr/bin/env cat /proc/loadavg` LOADAVG=`/usr/bin/env cat /proc/loadavg`
LOAD1=`echo $LOADAVG | /usr/bin/env awk {'print $1'}` LOAD1=`echo $LOADAVG | /usr/bin/env awk {'print $1'}`
LOAD5=`echo $LOADAVG | /usr/bin/env awk {'print $2'}` LOAD5=`echo $LOADAVG | /usr/bin/env awk {'print $2'}`
LOAD15=`echo $LOADAVG | /usr/bin/env awk {'print $3'}` LOAD15=`echo $LOADAVG | /usr/bin/env awk {'print $3'}`
echo "" echo ""
echo -e "\e[7m--- GOOD $TIME $USER ----\e[0m" echo -e "\e[7m--- GOOD $TIME $USER ----\e[0m"
echo "" echo ""
#MESSAGE=`/usr/bin/fortune | /usr/bin/cowsay` #MESSAGE=`/usr/bin/fortune | /usr/bin/cowsay`
#echo -e " $MESSAGE" #echo -e " $MESSAGE"
COLOR_COLUMN="\e[1m-" COLOR_COLUMN="\e[1m-"
COLOR_VALUE="\e[31m" COLOR_VALUE="\e[31m"
RESET_COLORS="\e[0m" RESET_COLORS="\e[0m"
echo -e " echo -e "
=========================================================================== ===========================================================================
$COLOR_COLUMN- Hostname$RESET_COLORS............: $COLOR_VALUE $HOSTNAME $RESET_COLORS $COLOR_COLUMN- Hostname$RESET_COLORS............: $COLOR_VALUE $HOSTNAME $RESET_COLORS
{% if common_show_ipv6 == true %} {% if common_show_ipv6 == true %}
$COLOR_COLUMN- IP Address (Main v4)$RESET_COLORS: $COLOR_VALUE $IP $RESET_COLORS $COLOR_COLUMN- IP Address (Main v4)$RESET_COLORS: $COLOR_VALUE $IP $RESET_COLORS
$COLOR_COLUMN- IP Address (Main v6)$RESET_COLORS: $COLOR_VALUE $IP6 $RESET_COLORS $COLOR_COLUMN- IP Address (Main v6)$RESET_COLORS: $COLOR_VALUE $IP6 $RESET_COLORS
{% else %} $COLOR_COLUMN- IP Address (Default)$RESET_COLORS: $COLOR_VALUE $IP $RESET_COLORS {% else %} $COLOR_COLUMN- IP Address (Default)$RESET_COLORS: $COLOR_VALUE $IP $RESET_COLORS
{% endif %} {% endif %}
{% if ansible_distribution == "Alpine" %} {% if ansible_distribution == "Alpine" %}
$COLOR_COLUMN- Release$RESET_COLORS.............: $COLOR_VALUE Alpine `/usr/bin/env cat /etc/os-release` $RESET_COLORS $COLOR_COLUMN- Release$RESET_COLORS.............: $COLOR_VALUE Alpine `/usr/bin/env cat /etc/os-release` $RESET_COLORS
{% else %} {% else %}
$COLOR_COLUMN- Release$RESET_COLORS.............: $COLOR_VALUE `/usr/bin/env cat /etc/os-release | /usr/bin/env grep PRETTY_NAME | /usr/bin/env cut -d '"' -f 2` $RESET_COLORS $COLOR_COLUMN- Release$RESET_COLORS.............: $COLOR_VALUE `/usr/bin/env cat /etc/os-release | /usr/bin/env grep PRETTY_NAME | /usr/bin/env cut -d '"' -f 2` $RESET_COLORS
{% endif %} {% endif %}
{% if ansible_distribution != "Alpine" %} {% if ansible_distribution != "Alpine" %}
$COLOR_COLUMN- Users$RESET_COLORS...............: $COLOR_VALUE Currently `users | wc -w` user(s) logged on $RESET_COLORS $COLOR_COLUMN- Users$RESET_COLORS...............: $COLOR_VALUE Currently `users | wc -w` user(s) logged on $RESET_COLORS
{% endif %} {% endif %}
=========================================================================== $RESET_COLORS =========================================================================== $RESET_COLORS
$COLOR_COLUMN- Current user$RESET_COLORS........: $COLOR_VALUE $USER $RESET_COLORS $COLOR_COLUMN- Current user$RESET_COLORS........: $COLOR_VALUE $USER $RESET_COLORS
$COLOR_COLUMN- Number of CPU$RESET_COLORS.......: $COLOR_VALUE $NUM_CPU $RESET_COLORS $COLOR_COLUMN- Number of CPU$RESET_COLORS.......: $COLOR_VALUE $NUM_CPU $RESET_COLORS
$COLOR_COLUMN- CPU usage$RESET_COLORS...........: $COLOR_VALUE $LOAD1 - $LOAD5 - $LOAD15 (1-5-15 min) $RESET_COLORS $COLOR_COLUMN- CPU usage$RESET_COLORS...........: $COLOR_VALUE $LOAD1 - $LOAD5 - $LOAD15 (1-5-15 min) $RESET_COLORS
$COLOR_COLUMN- Memory used$RESET_COLORS.........: $COLOR_VALUE $MEMORY (total-used-free) $RESET_COLORS $COLOR_COLUMN- Memory used$RESET_COLORS.........: $COLOR_VALUE $MEMORY (total-used-free) $RESET_COLORS
$COLOR_COLUMN- Swap in use$RESET_COLORS.........: $COLOR_VALUE $SWAP (total-used-free) MB $RESET_COLORS $COLOR_COLUMN- Swap in use$RESET_COLORS.........: $COLOR_VALUE $SWAP (total-used-free) MB $RESET_COLORS
$COLOR_COLUMN- Processes$RESET_COLORS...........: $COLOR_VALUE $PSA running $RESET_COLORS $COLOR_COLUMN- Processes$RESET_COLORS...........: $COLOR_VALUE $PSA running $RESET_COLORS
$COLOR_COLUMN- System uptime$RESET_COLORS.......: $COLOR_VALUE $upDays days $upHours hours $upMins minutes $upSecs seconds $RESET_COLORS $COLOR_COLUMN- System uptime$RESET_COLORS.......: $COLOR_VALUE $upDays days $upHours hours $upMins minutes $upSecs seconds $RESET_COLORS
{% if ansible_virtualization_type != "lxc" %} {% if ansible_virtualization_type != "lxc" %}
$COLOR_COLUMN- Disk space$RESET_COLORS..........: " $COLOR_COLUMN- Disk space$RESET_COLORS..........: "
for FS in ${FILESYSTEMS}; do for FS in ${FILESYSTEMS}; do
echo -e " $COLOR_COLUMN- ..........$RESET_COLORS..........: $COLOR_VALUE `df -H ${FS} | grep -v 'Filesystem' | grep -v '^[[:space:]]*$' | awk '{print $6 \" \" $4}'` remaining $RESET_COLORS" echo -e " $COLOR_COLUMN- ..........$RESET_COLORS..........: $COLOR_VALUE `df -H ${FS} | grep -v 'Filesystem' | grep -v '^[[:space:]]*$' | awk '{print $6 \" \" $4}'` remaining $RESET_COLORS"
done done
{% endif %} {% endif %}
echo -e " echo -e "
=========================================================================== ===========================================================================
" "
if [ -f /etc/motd ]; then if [ -f /etc/motd ]; then
/usr/bin/env cat /etc/motd /usr/bin/env cat /etc/motd
fi fi
else else
# Just exit :) # Just exit :)
exit 0 exit 0
fi; fi;