Skip to content

Instantly share code, notes, and snippets.

@anderiv
Last active August 29, 2015 13:56
Show Gist options
  • Save anderiv/9253519 to your computer and use it in GitHub Desktop.
Save anderiv/9253519 to your computer and use it in GitHub Desktop.
Add eth0 IP address to the system login prompt.
#!/bin/sh
# Save this file as /etc/network/if-up.d/mod-etc-issue and chmod +x
if [ "$METHOD" = loopback ]; then
exit 0
fi
# Only run from ifup.
if [ "$MODE" != start ]; then
exit 0
fi
IPADDR=`ip a s eth0 | grep inet | awk '{ print $2 }' | head -1`
# First time, back up /etc/issue
if [ ! -f /etc/issue.orig ]
then
cp /etc/issue /etc/issue.orig
fi
# "Reset" /etc/issue to original state
cp /etc/issue.orig /etc/issue
# Append IP address to /etc/issue
echo "eth0 address: $IPADDR" >> /etc/issue
echo "" >> /etc/issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment