Last active
December 16, 2015 08:28
-
-
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
This file contains 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/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 |
This file contains 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
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