Switch to dynamic /etc/issue generator

This commit is contained in:
Joshua Boniface 2024-05-24 10:36:19 -04:00
parent 1cd155885a
commit 2e5d23fd74
6 changed files with 86 additions and 33 deletions

View File

@ -468,12 +468,6 @@
- name: set PVC Plymouth theme as the default - name: set PVC Plymouth theme as the default
command: plymouth-set-default-theme -R pvc command: plymouth-set-default-theme -R pvc
# issue prompt
- name: install PVC /etc/issue file
template:
src: etc/issue.j2
dest: /etc/issue
# syslog # syslog
- name: install rsyslog and logrotate configs - name: install rsyslog and logrotate configs
template: template:
@ -638,24 +632,26 @@
tags: base-shell tags: base-shell
# motd # motd
- name: ensure update-motd and profile.d scripts are present - name: ensure update-issue, update-motd and profile.d scripts are present
template: template:
src: "{{ item.src }}" src: "{{ item.src }}"
dest: "{{ item.dest }}" dest: "{{ item.dest }}"
mode: 0755 mode: 0755
with_items: with_items:
- { src: "usr/local/sbin/update-issue.sh.j2", dest: "/usr/local/sbin/update-issue.sh" }
- { src: "usr/local/sbin/update-motd.sh.j2", dest: "/usr/local/sbin/update-motd.sh" } - { src: "usr/local/sbin/update-motd.sh.j2", dest: "/usr/local/sbin/update-motd.sh" }
- { src: "etc/profile.d/w.sh.j2", dest: "/etc/profile.d/w.sh" } - { src: "etc/profile.d/w.sh.j2", dest: "/etc/profile.d/w.sh" }
- { src: "etc/profile.d/pvc.sh.j2", dest: "/etc/profile.d/zzz_pvc.sh" } - { src: "etc/profile.d/pvc.sh.j2", dest: "/etc/profile.d/zzz_pvc.sh" }
register: profile_scripts register: profile_scripts
tags: base-shell tags: base-shell
- name: install update-motd crontab - name: install banner update crontabs
template: template:
src: "{{ item.src }}" src: "{{ item.src }}"
dest: "{{ item.dest }}" dest: "{{ item.dest }}"
mode: 0644 mode: 0644
with_items: with_items:
- { src: "etc/cron.d/update-issue.j2", dest: "/etc/cron.d/update-issue" }
- { src: "etc/cron.d/update-motd.j2", dest: "/etc/cron.d/update-motd" } - { src: "etc/cron.d/update-motd.j2", dest: "/etc/cron.d/update-motd" }
tags: base-shell tags: base-shell
@ -670,6 +666,11 @@
when: profile_scripts.changed when: profile_scripts.changed
tags: base-shell tags: base-shell
- name: run update-issue on change
command: /usr/local/sbin/update-issue.sh
when: profile_scripts.changed
tags: base-shell
# htop # htop
- name: install htop configuration - name: install htop configuration
template: template:

View File

@ -0,0 +1,5 @@
# cron file for update-issue
# {{ ansible_managed }}
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
@reboot root /usr/local/sbin/update-issue.sh &>/dev/null

View File

@ -1,4 +1,4 @@
# cron file for motd # cron file for update-motd
# {{ ansible_managed }} # {{ ansible_managed }}
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

View File

@ -1,20 +0,0 @@
███████████████████████ █████ █████ ███████████ ██ ██ ██
███████████████████████ █████ █████ ███████████ ██ ██ ██
████ █████ █████ ████
████ █████ █████ ████
███████████████████████ █████ █████ ████
███████████████████████ █████ █████ ████
███ █████████ ███████████████████████
███ ███████ ███████████████████████
Parallel Virtual Cluster (PVC) Node
Node name: {{ ansible_fqdn }}
Cluster name: {{ cluster_group }}
Managed by: {{ manager_email }}
Base System: {{ ansible_lsb.description }}
UNAUTHORIZED ACCESS IS PROHIBITED. ALL LOGIN ATTEMPTS WILL BE LOGGED.

View File

@ -0,0 +1,63 @@
#!/bin/bash
# Update dynamic ISSUE file
# {{ ansible_managed }}
set -o errexit
# Title-case generator
tc() { set ${*,,} ; echo ${*^} ; }
TMPFILE=$(mktemp)
TGTFILE=/etc/issue
VERSION_ID="$( cat /etc/debian_version )"
VERSION_CODENAME="$( grep '^VERSION_CODENAME=' /etc/os-release | awk -F'=' '{ print $2 }' )"
DEBVER="${NAME} ${VERSION_ID} \"$(tc ${VERSION_CODENAME} )\""
PVCVER="$( /usr/share/pvc/pvcnoded.py --version )"
echo >> $TMPFILE
echo " ███████████████████████ █████ █████ ███████████ ██ ██ ██ " >> $TMPFILE
echo " ███████████████████████ █████ █████ ███████████ ██ ██ ██ " >> $TMPFILE
echo " ████ █████ █████ ████ " >> $TMPFILE
echo " ████ █████ █████ ████ " >> $TMPFILE
echo " ███████████████████████ █████ █████ ████ " >> $TMPFILE
echo " ███████████████████████ █████ █████ ████ " >> $TMPFILE
echo " ███ █████████ ███████████████████████ " >> $TMPFILE
echo " ███ ███████ ███████████████████████ " >> $TMPFILE
echo >> $TMPFILE
echo >> $TMPFILE
echo -e " \033[01;34mParallel Virtual Cluster (PVC) Node\033[0m" >> $TMPFILE
echo >> $TMPFILE
echo -e " > \033[1;34mNode name:\033[0m \033[01;36m$(hostname)\033[0m" >> $TMPFILE
echo -e " > \033[1;34mCluster name:\033[0m \033[01;36m{{ cluster_group }}\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
echo -e " > \033[1;34mManaged by:\033[0m {{ manager_email }}" >> $TMPFILE
echo -e " > \033[1;34mPVC version:\033[0m ${PVCVER}" >> $TMPFILE
echo -e " > \033[1;34mBase system:\033[0m {{ ansible_lsb.description }}" >> $TMPFILE
echo -e " > \033[1;34mKernel:\033[0m $(/bin/uname -vm)" >> $TMPFILE
# Get machine information
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"
fi
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 >> $TMPFILE
echo " UNAUTHORIZED ACCESS IS PROHIBITED. ALL LOGIN ATTEMPTS WILL BE LOGGED." >> $TMPFILE
echo >> $TMPFILE
mv $TMPFILE $TGTFILE || rm $TMPFILE
chmod 644 $TGTFILE

View File

@ -15,11 +15,16 @@ NAME="$( grep '^NAME=' /etc/os-release | awk -F'"' '{ print $2 }' )"
VERSION_ID="$( cat /etc/debian_version )" VERSION_ID="$( cat /etc/debian_version )"
VERSION_CODENAME="$( grep '^VERSION_CODENAME=' /etc/os-release | awk -F'=' '{ print $2 }' )" VERSION_CODENAME="$( grep '^VERSION_CODENAME=' /etc/os-release | awk -F'=' '{ print $2 }' )"
DEBVER="${NAME} ${VERSION_ID} \"$(tc ${VERSION_CODENAME} )\"" DEBVER="${NAME} ${VERSION_ID} \"$(tc ${VERSION_CODENAME} )\""
PVCVER="$( /usr/share/pvc/pvcnoded.py --version )"
echo >> $TMPFILE echo >> $TMPFILE
echo -e "\033[01;34mParallel Virtual Cluster \033[01;36m(${DEBVER})\033[0m" >> $TMPFILE echo -e "\033[01;34mParallel Virtual Cluster (PVC) Node\033[0m" >> $TMPFILE
echo -e "> \033[1;34mHostname:\033[0m \033[01;36m$(hostname)\033[0m" >> $TMPFILE echo -e "> \033[1;34mNode name:\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 echo -e "> \033[1;34mCluster name:\033[0m \033[01;36m{{ cluster_group }}\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
echo -e "> \033[1;34mPVC version:\033[0m ${PVCVER}" >> $TMPFILE
echo -e "> \033[1;34mBase system:\033[0m {{ ansible_lsb.description }}" >> $TMPFILE
echo -e "> \033[1;34mKernel:\033[0m $(/bin/uname -vm)" >> $TMPFILE
# Get machine information # Get machine information
HARDWARE_DETAIL="$( /usr/sbin/dmidecode | grep -A7 'System Information' )" HARDWARE_DETAIL="$( /usr/sbin/dmidecode | grep -A7 'System Information' )"
@ -39,7 +44,6 @@ 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;34mModel:\033[0m ${HARDWARE_MODEL}" >> $TMPFILE
echo -e -n " \033[1;34mSerial:\033[0m ${HARDWARE_SERIAL}" >> $TMPFILE echo -e -n " \033[1;34mSerial:\033[0m ${HARDWARE_SERIAL}" >> $TMPFILE
echo >> $TMPFILE echo >> $TMPFILE
echo -e "> \033[1;34mKernel:\033[0m $(/bin/uname -srvmo)" >> $TMPFILE
mv $TMPFILE $TGTFILE || rm $TMPFILE mv $TMPFILE $TGTFILE || rm $TMPFILE
chmod 644 $TGTFILE chmod 644 $TGTFILE