Create welcome message with access information.
Usage: add script code snippet below to /etc/rc.local just before "exit 0"
Copyright 2015 Bitnami.com All Rights Reserved
DATA_DIR="/tmp/welcome"
get_local_ip_address () {
ip=`ifconfig | grep 'inet addr' | \
awk '{ print $2 }' | \
awk 'BEGIN { FS=":" } { print $2 }' | \
grep -v '127\.0\.0\.1' | \
head -1`
if [ "x$ip" = "x" ] ; then
return 1
fi
echo $ip
}
welcome_message_branding_logo() {
/bin/echo -e " ____ _ _ ";
/bin/echo -e " / ___| _ _ ___| | __ _| |__ ";
/bin/echo -e " \___ \| | | / __| | / _\` | '_ \ ";
/bin/echo -e " ___) | |_| \__ \ |__| (_| | |_) |";
/bin/echo -e " |____/ \__, |___/_____\__,_|_.__/ ";
/bin/echo -e " |___/ ";
}
welcome_message_header() {
/bin/echo -e "\033[0;36m"
welcome_message_branding_logo
/bin/echo -e "\033[0m"
/bin/echo -e "\033[1m*** Welcome to the System Software Lab. ***"
/bin/echo -e "\033[1m*** Built using Ubuntu 14.04 - Kernel \\\\r. ***\033[0m"
}
welcome_message_with_networking() {
/bin/echo -e "\033[1;33m"
/bin/echo -e "\033[1m*** You can access the guest at http://@@HOSTNAME@@ ***\033[0m"
}
welcome_message_no_networking() {
/bin/echo -e "\033[1;33m"
/bin/echo -e "\033[1m*** The machine could not configure the network interface. ***"
/bin/echo -e "\033[0m"
}
welcome_message_footer() {
password="password"
if [ "x$password" != "x" ] ; then
/bin/echo -e "\033[1;31m"
/bin/echo -e "**********************************************************"
/bin/echo -e " To access the console, please use login 'root'"
/bin/echo -e " and password '$password'"
/bin/echo -e "**********************************************************\033[0m"
fi
}
# initialize empty directory for template parts
mkdir -p "$DATA_DIR/welcome_message.d" && chmod 0700 "$DATA_DIR/welcome_message.d" && rm -f "$DATA_DIR/welcome_message.d/*"
welcome_message_header >$DATA_DIR/welcome_message.d/header
welcome_message_with_networking >$DATA_DIR/welcome_message.d/with_networking
welcome_message_no_networking >$DATA_DIR/welcome_message.d/no_networking
welcome_message_footer >$DATA_DIR/welcome_message.d/footer
IP=`get_local_ip_address`
if [ "x$IP" = "x" ] ; then
if [ -f "/etc/init.d/networking" ]; then
/etc/init.d/networking force-reload
IP=`get_local_ip_address`
elif [ -f "/etc/init.d/network" ]; then
/etc/init.d/network force-reload
IP=`get_local_ip_address`
fi
fi
if [ "x$IP" != "x" ] ; then
cat \
$DATA_DIR/welcome_message.d/header \
$DATA_DIR/welcome_message.d/with_networking \
$DATA_DIR/welcome_message.d/footer \
| sed "s,@@HOSTNAME@@,$IP,g" \
>/etc/issue
else
cat \
$DATA_DIR/welcome_message.d/header \
$DATA_DIR/welcome_message.d/no_networking \
$DATA_DIR/welcome_message.d/footer \
>/etc/issue
fi