2022-11-02 18:08:52 -04:00
|
|
|
#!/usr/bin/env bash
|
2019-06-09 00:11:06 -04:00
|
|
|
|
|
|
|
# Update dynamic MOTD file
|
|
|
|
# {{ ansible_managed }}
|
|
|
|
|
|
|
|
set -o errexit
|
|
|
|
|
|
|
|
TMPFILE=$(mktemp)
|
|
|
|
TGTFILE=/run/pvc-motd.dynamic
|
2019-06-18 10:59:31 -04:00
|
|
|
DEBVER="$( grep 'PRETTY_NAME=' /etc/os-release | awk -F'"' '{ print $2 }' )"
|
2019-06-09 00:11:06 -04:00
|
|
|
|
|
|
|
echo >> $TMPFILE
|
2022-11-02 18:08:52 -04:00
|
|
|
echo -e "\033[01;34mParallel Virtual Cluster \033[01;36m(${DEBVER})\033[0m" >> $TMPFILE
|
2022-11-02 18:44:49 -04:00
|
|
|
echo -e "> PVC \033[1;36m{% if is_coordinator %}coordinator{% else %}hypervisor{% endif %}\033[0m node \033[01;36m$(hostname)\033[0m" >> $TMPFILE
|
2019-06-09 00:11:06 -04:00
|
|
|
# Get machine information
|
2022-11-02 18:08:52 -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"
|
2021-10-11 14:59:55 -04:00
|
|
|
fi
|
2022-11-03 01:50:04 -04:00
|
|
|
echo -e "> Hardware Vendor: \033[1;36m${HARDWARE_VENDOR}\033[0m Model: \033[1;36m${HARDWARE_MODEL}\033[0m Serial: \033[1;36m${HARDWARE_SERIAL}\033[0m" >> $TMPFILE
|
2022-11-02 18:08:52 -04:00
|
|
|
echo -e "> $(/bin/uname -srvmo)" >> $TMPFILE
|
2019-06-09 00:11:06 -04:00
|
|
|
|
|
|
|
mv $TMPFILE $TGTFILE || rm $TMPFILE
|