Skip to content

Instantly share code, notes, and snippets.

@scompo
Created September 18, 2016 13:57
Show Gist options
  • Save scompo/c1e781af68f869626b018cec46e2356e to your computer and use it in GitHub Desktop.
Save scompo/c1e781af68f869626b018cec46e2356e to your computer and use it in GitHub Desktop.
Add IP address on login prompt
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
BASE_ISSUE_FILE="/etc/issue.base"
CURRENT_ISSUE_FILE="/etc/issue"
CURRENT_IP_ADDRESS=$(hostname -I)
cat $BASE_ISSUE_FILE > $CURRENT_ISSUE_FILE
echo "IP Address:" $CURRENT_IP_ADDRESS >> $CURRENT_ISSUE_FILE
exit 0
@scompo
Copy link
Author

scompo commented Sep 18, 2016

Setup

Copy original issue file

Execute the following command to copy the original /etc/issue to the new /etc/issue.base

sudo cp /etc/issue /etc/issue.base

Edit rc.local

Edit the /etc/rc.local file with the following command to make it look like this gist

sudo nano /etc/rc.local

Reboot

Reboot the system with the following command

sudo reboot

Check that everything is fine

The machine should reboot showing something like this.

Ubuntu 16.04.1 LTS ubuntu-base-vm tty1

IP Address: 192.168.1.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment