{"id":16358934,"url":"https://github.com/ar51an/raspberrypi-motd","last_synced_at":"2025-05-06T20:06:46.233Z","repository":{"id":47431052,"uuid":"402673095","full_name":"ar51an/raspberrypi-motd","owner":"ar51an","description":"Dynamic Message Of The Day (MOTD) For Raspberry Pi","archived":false,"fork":false,"pushed_at":"2024-06-04T07:18:40.000Z","size":75,"stargazers_count":62,"open_issues_count":4,"forks_count":13,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-10-12T02:07:07.502Z","etag":null,"topics":["bash","message-of-the-day","motd","motd-message","pam","pi","raspberry","raspberry-pi","raspberrypi","rpi","rpi4","script","shell"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ar51an.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-09-03T06:42:59.000Z","updated_at":"2024-10-06T16:16:01.000Z","dependencies_parsed_at":"2024-01-05T18:49:58.659Z","dependency_job_id":null,"html_url":"https://github.com/ar51an/raspberrypi-motd","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ar51an%2Fraspberrypi-motd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ar51an%2Fraspberrypi-motd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ar51an%2Fraspberrypi-motd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ar51an%2Fraspberrypi-motd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ar51an","download_url":"https://codeload.github.com/ar51an/raspberrypi-motd/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221810570,"owners_count":16884145,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","message-of-the-day","motd","motd-message","pam","pi","raspberry","raspberry-pi","raspberrypi","rpi","rpi4","script","shell"],"created_at":"2024-10-11T02:07:06.396Z","updated_at":"2024-10-28T08:57:12.970Z","avatar_url":"https://github.com/ar51an.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"## MOTD\nCustomized dynamic message of the day (motd) for Raspberry Pi\n\u003cdiv align=\"center\"\u003e\n\n![motd](https://img.shields.io/badge/-motd-D8BFD8?logo=themodelsresource\u0026logoColor=3a3a3d)\n\u0026nbsp;\u0026nbsp;[![release](https://img.shields.io/github/v/release/ar51an/raspberrypi-motd?display_name=release\u0026logo=rstudio\u0026color=90EE90\u0026logoColor=8FBC8F)](https://github.com/ar51an/raspberrypi-motd/releases/latest/)\n\u0026nbsp;\u0026nbsp;![downloads](https://img.shields.io/github/downloads/ar51an/raspberrypi-motd/total?color=orange\u0026label=downloads\u0026logo=github)\n\u0026nbsp;\u0026nbsp;![visitors](https://img.shields.io/endpoint?color=4883c2\u0026label=visitors\u0026logo=github\u0026url=https%3A%2F%2Fhits.dwyl.com%2Far51an%2Fraspberrypi-motd.json)\n\u0026nbsp;\u0026nbsp;![lang](https://img.shields.io/badge/lang-Bash-5F9EA0?logo=gnubash\u0026logoColor=4EAA25)\n\u0026nbsp;\u0026nbsp;![license](https://img.shields.io/badge/license-MIT-CED8E1)\n\u003c/div\u003e\n\n### Preview\n\u003cdiv align=\"center\"\u003e\n\n![WithCount](https://github.com/ar51an/raspberrypi-motd/assets/11185794/fbf346a2-6978-427b-b042-8fd5a5af3e8e)\n\n![WithoutCount](https://github.com/ar51an/raspberrypi-motd/assets/11185794/f5f6c3ca-915e-439e-9dbb-8c376c156633)\n\u003c/div\u003e\n\n---\n\u003cdiv align=\"justify\"\u003e\n\n### Intro\nMany folks use Raspberry Pi as headless. If you use SSH more often to connect Raspberry Pi and interested in changing the MOTD (message of the day), keep on reading. **The goal is to create simple, swift and useful motd**.\n\u003cbr/\u003e\n\nLack of available update count in RaspiOS motd is the triggering point to develop this motd. Traditionally `apt-check` utility in `update-notifier-common` package was used to fetch the available update count. This package is no longer available from `buster` onwards, its functionality is merged into `unattended-upgrades` add-on package. I used `apt-get` to parse the required information.\n\u003cbr/\u003e\n\nThe process used for the motd is the same as RaspiOS or Ubuntu uses to show the motd dynamically. There is no additional package or third party tool used. It is written in bash and executes using the same mechanism as the default motd. There are multiple commands for retrieving the same information. I tested various commands for each info and used that took the least amount of time. This dynamic motd takes approximately 1 sec after authentication. This is the fastest you can get with all the information it is displaying.\n\u003cbr/\u003e\n\n#### Specs:\n\u003e |HW                      |OS                           |\n\u003e |:-----------------------|:----------------------------|\n\u003e |`Raspberry Pi 4 Model B`|`raspios-bookworm-arm64-lite`|\n#\n### Steps\n#### ❯ Remove Default MOTD\n\n* Delete `/etc/motd`. This file contains the static text about Debian GNU/Linux liability. Alternatively you can keep a backup of this file at some place.\n  \u003e `sudo rm /etc/motd`  \n\n* Delete `/etc/update-motd.d/10-uname`. This file prints the OS version dynamically to the default message. New motd will print a trimmed down version of OS.  \n  \u003e `sudo rm /etc/update-motd.d/10-uname`  \n\n* Modify `/etc/ssh/sshd_config`. This file prints last login timestamp and location. New motd will print last login timestamp and location.  \n  \u003e `sudo nano /etc/ssh/sshd_config`  \n  \u003e Add: `PrintLastLog no`  \n  \u003e Save \u0026 Exit  \n  \u003e Restart sshd: `sudo systemctl restart sshd`  \n\n#\n\u003e **_NOTE:_**  \n\u003e Default motd is completely removed. Reconnect ssh session and if you followed the steps correctly you will not see any motd.  \n#\n\n#### ❯ Implement New MOTD\n* Copy `10-welcome`, `15-system` and `20-update` scripts from the latest release under `update-motd.d` dir to `/etc/update-motd.d` dir. \nMake sure scripts are under the ownership of root and are executable.\n  \u003e **Change ownership [If needed]:**  \n  \u003e `sudo chown root:root /etc/update-motd.d/\u003cscript-name\u003e`  \n\n  \u003e **Make scripts executable [If needed]:**  \n  \u003e `sudo chmod +x /etc/update-motd.d/\u003cscript-name\u003e`  \n\n  \u003e ![update-motd_files](https://user-images.githubusercontent.com/11185794/202982786-76711b90-6cc9-4680-afb5-de07fa1da446.png)\n\n#\n\u003e **_NOTE:_**  \n\u003e If you noticed all the scripts have names starting with a number. Dynamic contents of the motd are created by PAM (Pluggable Authentication Module) running bash scripts from /etc/update-motd.d dir. Scripts are read in numeric order and do not need a file extension. In the default motd it was executing 10-uname script to show the OS version which we deleted earlier.\n#\n\n* Create static contents of new motd. This is not entirely static, PAM will execute static script. Static script is created from dynamic script once a day with systemd timer. It minimizes startup delay. Keeping it completely dynamic increases startup delay to 3-4 seconds after authentication.\n  * Create dir /etc/update-motd-static.d  \n    \u003e `sudo mkdir /etc/update-motd-static.d/`  \n\n  * Copy `20-update` script from the latest release under `update-motd-static.d` dir to this newly created dir `/etc/update-motd-static.d`. Make sure script is under the ownership of root and it is executable.\n    \u003e **Change ownership [If needed]:**  \n    \u003e `sudo chown root:root /etc/update-motd-static.d/20-update`  \n\n    \u003e **Make script executable [If needed]:**  \n    \u003e `sudo chmod +x /etc/update-motd-static.d/20-update`  \n\n    \u003e ![update-motd-static_files](https://user-images.githubusercontent.com/11185794/202983089-6b303358-9b27-4005-bf27-170c16141cc8.png)\n\n  * Run dynamic script to update the static script `/etc/update-motd.d/20-update` with pending update count (if any). We will automate this process through systemd timer.\n    \u003e **Run script:**  \n    \u003e `sudo run-parts /etc/update-motd-static.d`  \n\n#\n\u003e **_NOTE:_**  \n\u003e New motd is implemented, pending few automations. Let's test new motd to verify that everything is working properly. **Either** reconnect ssh session **or** run the new motd from the same shell. If steps were followed correctly you will see new motd, something similar to the preview.  \n\u003e \u003e **Run motd from the same shell:**  \n\u003e \u003e `sudo run-parts /etc/update-motd.d`\n#\n\n#### ❯ Automation\n\n* We need to automate the process of finding pending OS update count. It is scheduled to run once a day at 8:00pm. You can change the time and frequency based on your preference.\n\n  * **Systemd Timer**  \n\t  Copy `motd-update.timer` and `motd-update.service` from the latest release under `systemd-timer` dir to `/etc/systemd/system`. Make sure files are under the ownership of root. Enable and start timer.  \n    \u003e **Change ownership [If needed]:**  \n    \u003e `sudo chown root:root /etc/systemd/system/motd-update.timer`  \n    \u003e `sudo chown root:root /etc/systemd/system/motd-update.service`  \n    \u003e **Enable timer:**  \n    \u003e `sudo systemctl enable motd-update.timer`  \n    \u003e **Start timer:**  \n    \u003e `sudo systemctl start motd-update.timer`  \n    \u003e **List all timers [If needed]:**  \n    \u003e `systemctl list-timers`  \n\n* Last step. We need to reset the pending update count in motd as soon as we update the OS, otherwise count will be updated at the next run of systemd timer. Suppose you update system with commands `sudo apt update` \u0026 `sudo apt full-upgrade`. **You need to run command `sudo run-parts /etc/update-motd-static.d` at the end.** It will reset the update count in motd after OS update. Whatever your preferred way to update the OS, run this command at the very end.\n  * I update OS with a bash script `update.sh` after seeing pending updates in motd. It takes care of everything that includes **update OS, cleanup and update motd count**. `update.sh` is available in the latest release under `update-os` dir. Execution screenshot is shown in the repo under `update-os` dir. Script is well documented. **Open and check the commands once before execution.**  \nYou can add switch -y to `sudo apt full-upgrade` command to bypass the yes/no prompt. I prefer not to have it as a last chance to review. Script does cleanup as well using `sudo apt --purge autoremove` \u0026 `sudo apt clean`, you can remove them if you prefer not to run these after OS update.  \n\n#\n\u003e **_NOTE:_**  \n\u003e If you are not seeing the exact colors in your motd as in the preview, check the Putty section below for color scheme.\n#\n\n### Scripts Info\n#### ❯ /etc/update-motd.d/10-welcome\n\u003e Displays the raspberry model, welcome user message, current timestamp and kernel version.\n\n#### ❯ /etc/update-motd.d/15-system\n\u003e Shows various details of the system. It includes temperature, memory, running processes and others. Few labels are trimmed down, like `Procs` for `Processes`, `Temp` for `Temperature`, `Last` for `Last Login`. You can use full labels according to your preference and arrange them accordingly.\n\n#### ❯ /etc/update-motd.d/20-update\n\u003e This static script displays available update count. It is generated by `/etc/update-motd-static.d/20-update`.\n\n#### ❯ /etc/update-motd-static.d/20-update\n\u003e Calculates available update count and generates the static script for motd display. It can be expanded to show the security update count separately like Ubuntu.\n\n#\n### PuTTY\nI use slight modification of `Liquid Carbon` PuTTY theme from [AlexAkulov](https://github.com/AlexAkulov/putty-color-themes/blob/master/23.%20Liquid%20Carbon.reg). Modified theme `Liquid Carbon Mod.reg` is available under this repo folder `putty` along with screenshots of PuTTY settings.\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Far51an%2Fraspberrypi-motd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Far51an%2Fraspberrypi-motd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Far51an%2Fraspberrypi-motd/lists"}