-
-
Save samrocketman/488c735fc2339a06bac2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# based on http://offbytwo.com/2008/05/09/show-ip-address-of-vm-as-console-pre-login-message.html | |
# need to be root to write out these files | |
if [ `id -u` != 0 ]; then | |
echo "Need to run as root. Maybe use sudo..." | |
exit | |
fi | |
GET_IP_ADDRESS='/usr/local/bin/get-ip-address' | |
if [ ! -f $GET_IP_ADDRESS ]; then | |
cat >$GET_IP_ADDRESS <<EOF | |
#!/bin/sh | |
ip address show dev eth0 | grep "inet " | awk '{ print \$2 }' | awk -F/ '{ print \$1 }' | |
EOF | |
chmod 0755 $GET_IP_ADDRESS | |
fi | |
if [ ! -f '/etc/issue-standard' ]; then | |
cp /etc/issue /etc/issue-standard | |
cat >'/etc/network/if-up.d/show-ip-before-login' <<EOF | |
#/bin/sh | |
if [ "\$METHOD" = loopback ]; then | |
exit 0 | |
fi | |
# Only run from ifup. | |
if [ "\$MODE" != start ]; then | |
exit 0 | |
fi | |
grep -v "^\$" /etc/issue-standard >/etc/issue | |
echo -n " " >>/etc/issue | |
$GET_IP_ADDRESS >>/etc/issue | |
echo "" >> /etc/issue | |
EOF | |
chmod 0755 /etc/network/if-up.d/show-ip-before-login | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment