2023-09-01 15:42:29 -04:00
|
|
|
#!/bin/bash
|
2023-09-01 15:42:19 -04:00
|
|
|
|
|
|
|
# Update dynamic MOTD file
|
|
|
|
# {{ ansible_managed }}
|
|
|
|
|
|
|
|
set -o errexit
|
|
|
|
|
2023-09-01 15:42:29 -04:00
|
|
|
# Title-case generator
|
|
|
|
tc() { set ${*,,} ; echo ${*^} ; }
|
|
|
|
|
2023-09-01 15:42:19 -04:00
|
|
|
TMPFILE=$(mktemp)
|
|
|
|
TGTFILE=/run/pvc-motd.dynamic
|
2023-09-01 15:42:29 -04:00
|
|
|
|
|
|
|
NAME="$( grep '^NAME=' /etc/os-release | awk -F'"' '{ print $2 }' )"
|
2023-09-01 15:42:29 -04:00
|
|
|
VERSION_ID="$( cat /etc/debian_version )"
|
2023-09-01 15:42:29 -04:00
|
|
|
VERSION_CODENAME="$( grep '^VERSION_CODENAME=' /etc/os-release | awk -F'=' '{ print $2 }' )"
|
|
|
|
DEBVER="${NAME} ${VERSION_ID} \"$(tc ${VERSION_CODENAME} )\""
|
2023-09-01 15:42:19 -04:00
|
|
|
|
|
|
|
echo >> $TMPFILE
|
2023-09-01 15:42:29 -04:00
|
|
|
echo -e "\033[01;34mParallel Virtual Cluster \033[01;36m(${DEBVER})\033[0m" >> $TMPFILE
|
2024-01-18 16:19:43 -05:00
|
|
|
echo -e "> \033[1;34mHostname:\033[0m \033[01;36m$(hostname)\033[0m" >> $TMPFILE
|
|
|
|
echo -e "> \033[1;34mSystem Type:\033[0m: PVC \033[1;36m{% if is_coordinator %}coordinator{% else %}hypervisor{% endif %}\033[0m node" >> $TMPFILE
|
|
|
|
|
2023-09-01 15:42:19 -04:00
|
|
|
# Get machine information
|
2023-09-01 15:42:29 -04:00
|
|
|
HARDWARE_DETAIL="$( /usr/sbin/dmidecode | grep -A7 'System Information' )"
|
|
|
|
HARDWARE_VENDOR="$( grep 'Manufacturer:' <<<"${HARDWARE_DETAIL}" | sed 's/Manufacturer: //; s/\s*$//g; s/^\s*//g' )"
|
|
|
|
if [[ -z ${HARDWARE_VENDOR} ]]; then
|
|
|
|
HARDWARE_VENDOR="Unknown"
|
|
|
|
fi
|
|
|
|
HARDWARE_MODEL="$( grep 'Product Name:' <<<"${HARDWARE_DETAIL}" | sed 's/Product Name: //; s/\s*$//g; s/^\s*//g' )"
|
|
|
|
if [[ -z ${HARDWARE_MODEL} ]]; then
|
|
|
|
HARDWARE_MODEL="Unknown"
|
|
|
|
fi
|
|
|
|
HARDWARE_SERIAL="$( grep 'Serial Number:' <<<"${HARDWARE_DETAIL}" | sed 's/Serial Number: //; s/\s*$//g; s/^\s*//g' )"
|
|
|
|
if [[ -z ${HARDWARE_SERIAL} ]]; then
|
|
|
|
HARDWARE_SERIAL="Unknown"
|
2023-09-01 15:42:27 -04:00
|
|
|
fi
|
2024-01-18 16:19:43 -05:00
|
|
|
echo -e -n "> \033[1;34mHardware Vendor:\033[0m ${HARDWARE_VENDOR}" >> $TMPFILE
|
|
|
|
echo -e -n " \033[1;34mModel:\033[0m ${HARDWARE_MODEL}" >> $TMPFILE
|
|
|
|
echo -e -n " \033[1;34mSerial:\033[0m ${HARDWARE_SERIAL}" >> $TMPFILE
|
|
|
|
echo >> $TMPFILE
|
|
|
|
echo -e "> \033[1;34mKernel:\033[0m $(/bin/uname -srvmo)" >> $TMPFILE
|
2023-09-01 15:42:19 -04:00
|
|
|
|
|
|
|
mv $TMPFILE $TGTFILE || rm $TMPFILE
|