Skip to content

Instantly share code, notes, and snippets.

@korovamilk
Created April 5, 2013 15:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save korovamilk/5320187 to your computer and use it in GitHub Desktop.
Save korovamilk/5320187 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Filename: boot_prompt.sh
# Description: Shows connected interface(s) at boot and related ip address(es) on tty login prompt
# Usage: Put it somewhere (ie. /etc/init.d/) and then add its full path entry to /etc/rc.d/rc.local
#
# Author: marco[dot]agate@gmail[dot]com
# Version: 201304051644
DSTFILE="/etc/issue"
KEEPLINE=$(head -n 1 ${DSTFILE})
IFACE_UP=$(/sbin/ifconfig | grep 'Bcast:' -B1 | grep -v inet | grep -v - -- | awk '{print $1}')
echo ${KEEPLINE} | sed 's/\\\\/\\/g' > ${DSTFILE}
echo >> $DSTFILE
if [ -z "$IFACE_UP" ]; then
echo "\n No active connection found." >> $DSTFILE
else
echo "Currently connected via:">> $DSTFILE
for IFACE in $IFACE_UP;
do IPADDR=$(/sbin/ifconfig $IFACE | grep 'Bcast:' | cut -d: -f2 | awk '{ print $1}')
echo " $IFACE $IPADDR" >> $DSTFILE
done
fi
echo >> $DSTFILE
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment