#! /bin/sh
# Written by Miquel van Smoorenburg <miquels@drinkel.ow.org>.
# Modified for Debian GNU/Linux by Ian Murdock <imurdock@gnu.ai.mit.edu>.
# Modified for Debian by Christoph Lameter <clameter@debian.org>
# Modified for linuxlogo by Steve Kostecke <steve@debian.org>

PATH=/bin:/usr/bin:/sbin:/usr/sbin
DAEMON=/usr/bin/linux_logo
FLAGS="defaults 99"

# /etc/issue may be diverted to
REALISSUE=/etc/issue.linuxlogo

# Set the options to control the logo appearance.  See the manpage
# for the available options.  This really should be replaced with
# a conf file.
OPTS="-n -o 4"

[ -f $DAEMON ] || exit 0

# Check to see if /etc/issue has been diverted
DIVERT=`dpkg-divert --list linuxlogo | cut --delimiter=" " --fields=1`

update_the_logo() {
    echo -n "Updating the Linux Logo..."
    clear > /etc/issue
    echo -e "\f" >> /etc/issue
    $DAEMON $OPTS >> /etc/issue
    echo -e "\n" >> /etc/issue
    [ -f "$REALISSUE" ] && cat "$REALISSUE" >> /etc/issue
    echo "done."
}

case "$1" in
  start)
    if [ "$DIVERT" ]; then
      update_the_logo
    else
      $DAEMON $OPTS 
    fi
    ;;
  stop)
    ;;
  restart)
    update_the_logo
    ;;
  reload|force-reload|*)
    echo "Usage: $0 {start|stop|restart}"
    exit 1
    ;;
esac

exit 0
