Skip to content

Instantly share code, notes, and snippets.

@dsingley
Last active December 16, 2015 08:28
Show Gist options
  • Save dsingley/5405629 to your computer and use it in GitHub Desktop.
Save dsingley/5405629 to your computer and use it in GitHub Desktop.
display the current IP address on the console of a RHEL (or derivative) server
#!/bin/bash
ip_address="$(ip addr show $1 2>/dev/null | awk '/inet / {print $2}' | sed -e 's/\/.*//')"
if [ "${ip_address}" ]; then
formatted_address="$(printf "%-10s%s\n" "$1:" ${ip_address})"
sed -e "s/IP_ADDRESS/${formatted_address}/" /etc/issue.TEMPLATE > /etc/issue
else
cp /etc/issue.DIST /etc/issue
fi
cp /etc/issue /etc/issue.DIST
cp /etc/issue /etc/issue.TEMPLATE
echo IP_ADDRESS >> /etc/issue.TEMPLATE
echo >> /etc/issue.TEMPLATE
chmod +x /etc/sysconfig/network-scripts/ifup-local
ln -s /etc/sysconfig/network-scripts/ifup-local /sbin/ifup-local
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment