Add IP Information To issue File
Script:
#!/bin/bash
IP=${1:-`hostname -I`}
# Add "IP ADDRESS" line if not already found
grep "IP ADDRESS" /etc/issue > /dev/null
if [ "$?" -ne "0" ]; then
echo >> /etc/issue
echo "IP ADDRESS" >> /etc/issue
fi
sed -i s/"IP ADDRESS.*"/"IP ADDRESS : $IP"/g /etc/issue
systemd service file:
[Unit]
Description=Add IP address to /etc/issue
After=network-online.target
[Service]
Type=oneshot
ExecStart=/usr/local/sbin/update-issue-with-ip
RemainAfterExit=true
ExecStop=/usr/local/sbin/update-issue-with-ip UNKNOWN
[Install]
WantedBy=multi-user.target
Do your daemon-reload and enable --now and you should be good to go.
Source
Commentary
My changes from the source:
- I renamed the script from the example as /usr/local/sbin/update-issue-with-ip
- the script is in /usr/local/sbin instead of /usr/bin
- my .service file lives in /etc/systemd/system
This is probably my old-school unix history showing more than anything else. Strictly speaking since this isn't a user-interactive script, the script should probably live in /usr/local/libexec somewhere.