For When You Can't Have The Real Thing
[ start | index | login ]
start > Fedora > 34 > Add IP Information To issue File

Add IP Information To issue File

Created by dave. Last edited by dave, 190 days ago. Viewed 173 times. #2
[diff] [history] [edit] [rdf]
labels
attachments

Add IP information to /etc/issue

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

>>Steve Parker

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.
no comments | post comment
This is a collection of techical information, much of it learned the hard way. Consider it a lab book or a /info directory. I doubt much of it will be of use to anyone else.

Useful:


snipsnap.org | Copyright 2000-2002 Matthias L. Jugel and Stephan J. Schmidt