#! /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>

# Default Options
# OPTIONS="-tThe Universal Operating System"
# Use this option line to display the classic logo
OPTIONS="-c -o 4 -n"
# Use this option line to display the banner logo
# OPTIONS="-b"

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

[ -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" $OPTIONS >> /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" $OPTIONS
    fi
    ;;
  stop)
    ;;
  restart|force-reload)
    update_the_logo
    ;;
  *)
    OPTS=`grep "^.*)$" $0 | tr -d '\n ' | sed -e s/\)/\|/g -e s/\|.\|$//`
    echo "Usage: $0 {$OPTS}"
    ;;
esac

exit 0

