`motd` with some essential info

January 8, 2024, 20:50

oops.se

# Neofetch as motd (Message of the day) Install neofetch sudo apt install neofetch Update Neofetch to version Neofetch 7.2.8 that has CPU temp feature that works on Raspberry Pi.
wget https://raw.githubusercontent.com/LanikSJ/neofetch/master/neofetch
chmod +x neofetch
sudo chown root:root /usr/bin/neofetch
sudo mv neofetch /usr/bin/neofetch
## Delete the default motd sudo mv /etc/motd /etc/motd.org ## Create a neofetch.sh in /etc/profile.d Edit sudo nano /etc/profile.d/neofetch.sh An past the text below into /etc/profile.d/neofetch.sh
# neofetch as Message Of The Day (motd)
export TEXTDOMAIN=Linux-PAM
. gettext.sh
neofetch
## Change ownership of neofetch.sh to root sudo chown root:root /etc/profile.d/neofetch.sh ## Change SSH Server config In /etc/ssh/sshd_config replace or add the string #PrintLastLog yes with PrintLastLog no ## Tweaking the neofetch config file First you need to run neofetch, neofetch to create a default configuration file. Then edit to your liking, nano /home/<user>/.config/neofetch/config.conf ## CPU temperature Change cpu_temp="off" to cpu_temp="C". This needs Neofetch 7.2.8 ## Insert this to show the outdoor temperature:
   # Replace "Stockholm" with your city
   prin "Weather" "$(curl wttr.in/Sstockholm?0?q?T | awk '/°(C|F)/ {printf $(NF-1) $(NF) " ("a")"} /,/ {a=$0}')"
## Replace automatic with Raspbian as Raspberry Pi OS (64-bit) is detected as "Debian".
ascii_distro="Raspbian"
When you log in with SSH the next time you will be grated with a nice "Raspberry Pi" info.

oops.se

# Example
print_info() {
    info title
    info underline
    info "OS      " distro
    info "Hardware" model
    info "Kernel  " kernel
    prin
    info "Uptime  " uptime
    prin
    #info "Shell   " shell
    info "Terminal" term
    prin
    info "CPU" cpu
    info "GPU" gpu
    # prin "CPU Temp" "$(vcgencmd measure_temp | awk -F '=' '{print $2}')"
    info "Memory" memory
    info "Disk" disk
    prin
    info "Local IP" local_ip
    info "Public IP" public_ip
    prin
    info "Users" users
    prin
    # https://wttr.in/:help
    prin "Weather" "$(curl wttr.in/Stockholm?0?q?T | awk '/°(C|F)/ {printf $(NF-1) $(NF) " ("a")"} /,/ {a=$0}')"
}
To add the last time an apt update/upgrade was executed.
    prin "Last updated" "$(cat /var/log/apt/history.log | grep 'End-Date' | tail -1 | sed 's/End-Date://g')"
Check if there are any new packages to update. This can take a little time.
    prin "Packages that can be updated" "$(apt-get upgrade -s |grep -P '^\d+ upgraded'|cut -d" " -f1)"