#!/bin/bash

[ -e /etc/boottime.stamp ] || touch /etc/boottime.stamp

unset IP
if [ -f /etc/xensource-inventory ] ; then
    eval $(sed -n '/^MANAGEMENT_INTERFACE=/ p' /etc/xensource-inventory)
fi
[ -z "$MANAGEMENT_INTERFACE" ] || {
   IP=$(ip addr show dev $MANAGEMENT_INTERFACE | awk '/ inet / { print $2 }')
   IP=${IP%%/*}
}
: ${IP:="IP address not configured"}

unset FINGERPRINT
if [ -f /etc/xensource/xapi-ssl.pem ] ; then
    FINGERPRINT=`openssl x509 -in /etc/xensource/xapi-ssl.pem -fingerprint -noout`
    FINGERPRINT=${FINGERPRINT#SHA1 Fingerprint=}
fi
cat > $mnt/etc/issue <<EOF
Citrix XenServer Host 5.5.0-25727p

System Booted: `date -r /etc/boottime.stamp +"%F %R"`

Your XenServer Host has now finished booting. To manage this
server please use the Citrix XenCenter application.
You can install XenCenter for Windows from the XenServer installation media.

You can connect to this system using one of the following network
addresses:

$IP

EOF

if [ -n "${FINGERPRINT}" ] ; then
    cat >> $mnt/etc/issue <<EOF
XenServer Host SSL certificate fingerprint:
$FINGERPRINT


EOF
fi

exit 0

