#!/bin/sh

set -e

test -f /sbin/SVGATextMode || exit 0

case "$1" in

# all the settings including the default font and default mode can be configured
# in /etc/TextConfig, therefore no arguments are needed for SVGATextMode

	start|restart|force-reload)
		echo -n "Invoking SVGATextMode... "
		if egrep '.+' /proc/fb >/dev/null 2>&1; then
			echo -n "detected framebuffer"
			if [ -f /etc/default/STM_nocheckfb ]; then
				echo -n "(ignored, starting STM)... "
			else
				echo "(aborting) see STM_nocheckfb(5)."
				exit 0
			fi
		fi
		/sbin/SVGATextMode>/dev/null
		echo "done."
		;;

        stop)
# Since stm is not really a daemon, stop does nothing
		exit 0
		;;
	*)
		echo "Usage: /etc/init.d/svgatextmode {start|stop|restart|force-reload}"
		exit 1
esac
