From 47dfd8aa22e0677f3286dfbb5385a6acd04200f1 Mon Sep 17 00:00:00 2001 From: richard Date: Sun, 21 Aug 2022 10:34:04 -0400 Subject: [PATCH] setup ssh splash screen using motd for debian bullseye --- ansible-5/roles/common/files/motd/reboot_required.sh | 5 +++++ ansible-5/roles/common/files/motd/systats.sh | 1 + .../roles/common/files/motd/updates_available.sh | 7 +++++++ ansible-5/roles/common/tasks/main.yml | 4 ++-- ansible-5/roles/common/tasks/motd.yml | 12 ++++++++---- 5 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 ansible-5/roles/common/files/motd/reboot_required.sh create mode 100644 ansible-5/roles/common/files/motd/updates_available.sh diff --git a/ansible-5/roles/common/files/motd/reboot_required.sh b/ansible-5/roles/common/files/motd/reboot_required.sh new file mode 100644 index 0000000..be8b476 --- /dev/null +++ b/ansible-5/roles/common/files/motd/reboot_required.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +if [ -x /usr/lib/update-notifier/update-motd-reboot-required ]; then + exec /usr/lib/update-notifier/update-motd-reboot-required +fi diff --git a/ansible-5/roles/common/files/motd/systats.sh b/ansible-5/roles/common/files/motd/systats.sh index 09212d4..ec2b6ff 100644 --- a/ansible-5/roles/common/files/motd/systats.sh +++ b/ansible-5/roles/common/files/motd/systats.sh @@ -143,6 +143,7 @@ swap_usage=`free -m | awk '/Swap:/ { printf("%3.1f%%", $3/$2*100) }'` #getboardtemp # DISPLAY +echo echo "System information as of: $date" echo display "System load" "${load%% *}" "${critical_load}" "0" "" "${load#* }" diff --git a/ansible-5/roles/common/files/motd/updates_available.sh b/ansible-5/roles/common/files/motd/updates_available.sh new file mode 100644 index 0000000..9377fdc --- /dev/null +++ b/ansible-5/roles/common/files/motd/updates_available.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +stamp="/var/lib/update-notifier/updates-available" + +[ ! -r "$stamp" ] || cat "$stamp" + +find $stamp -newermt 'now-7 days' 2> /dev/null | grep -q -m 1 '.' || /usr/share/update-notifier/notify-updates-outdated diff --git a/ansible-5/roles/common/tasks/main.yml b/ansible-5/roles/common/tasks/main.yml index 70c2aed..8adea42 100644 --- a/ansible-5/roles/common/tasks/main.yml +++ b/ansible-5/roles/common/tasks/main.yml @@ -8,8 +8,8 @@ # update packages to latest - include_tasks: apply_updates.yml -#- name: update login screen -# include_tasks: motd.yml +- name: update login screen + include_tasks: motd.yml - name: update fstab include_tasks: update_fstab.yml diff --git a/ansible-5/roles/common/tasks/motd.yml b/ansible-5/roles/common/tasks/motd.yml index 5929a15..d446e80 100644 --- a/ansible-5/roles/common/tasks/motd.yml +++ b/ansible-5/roles/common/tasks/motd.yml @@ -12,10 +12,16 @@ with_items: - lsb-release - figlet - - update-motd +# - update-motd - lm-sensors - when: ansible_architecture != 'armv7l' +- name: Create /etc/update-motd.d/ if it does not exist + ansible.builtin.file: + path: /etc/update-motd.d/ + state: directory + owner: root + group: root + mode: '0755' - name: remove help text file: @@ -24,7 +30,6 @@ with_items: - /etc/update-motd.d/10-help-text - /etc/update-motd.d/51-cloudguest - when: ansible_architecture != 'armv7l' - name: add new info @@ -35,4 +40,3 @@ with_items: - { src: motd/hostname.sh, dest: 10-hostname } - { src: motd/systats.sh, dest: 11-sysstats} - when: ansible_architecture != 'armv7l'