I want to make when CentOS start in init 3 to show me my ip addr, before log in. For Example:
CentOS Realese 6.5(Final)
Kernel 2.6..
ip addr: 192.168.1.1
or something like that.
I make script which is:
#!/bin/bash
ifconfig eth0 | grep 'inet addr'
but, I don't know where I put it.
I try in rc.local (with "cat" and him path) but obviously it is not right place, or I make something wrong. And I try in /etc/issue , but and there maybe I make something wrong.
Place this code into /etc/rc.d/rc.local and install banner application tho show BIG ip address
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
SETCOLOR_SUCCESS="echo -en \\033[1;32m"
SETCOLOR_FAILURE="echo -en \\033[1;31m"
SETCOLOR_WARNING="echo -en \\033[1;33m"
SETCOLOR_NORMAL="echo -en \\033[0;39m"
SETCOLOR_BLUE="echo -en \\033[0;36m"
touch /var/lock/subsys/local
${SETCOLOR_BLUE}
IP=`/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
${SETCOLOR_NORMAL}
#IP=255.255.255.255
if [[ -z "${IP}" ]]; then
${SETCOLOR_FAILURE}
echo "######################################################################"
echo "## ##"
echo "## Please setup networking and restart virtual machine! ##"
echo "## ##"
echo "######################################################################"
else
${SETCOLOR_WARNING}
echo "Local IP is"
COLUMNS=200 banner ${IP}
fi
${SETCOLOR_SUCCESS}
echo "Use root/password to login"
${SETCOLOR_NORMAL}