#!/bin/sh
/sbin/service cups status &>/dev/null
case $? in
0)	exec htmlview http://localhost:631/
	;;
*)	# CUPS isn't running...
	if [ `id -u` = 0 ]; then
		/sbin/service cups start &>/dev/null
		if /sbin/service cups status &>/dev/null; then
			exec htmlview http://localhost:631/
		fi
	fi
	HELP="CUPS must be running in order to use this configuration tool.
Please start CUPS by running
	\"/sbin/service cups start\"
as root.

If you are currently running a different print server (such as LPRng), you
may have to turn it off before CUPS can be started, e.g. by running
	\"/sbin/service lpd stop\"
as root.

To switch print systems permanently, use
	\"/usr/sbin/alternatives --config print\"
"
	if [ -n "$DISPLAY" ]; then
		if [ -x /usr/X11R6/bin/xmessage ]; then
			exec /usr/X11R6/bin/xmessage "$HELP"
		elif [ -x /usr/bin/konsole ]; then
			exec /usr/bin/konsole -e /bin/sh -c "echo \"$HELP\" ; read"
		elif [ -x /usr/bin/gnome-terminal ]; then
			exec gnome-terminal -e /bin/sh -c "echo \"$HELP\" ; read"
		elif [ -x /usr/X11R6/bin/xterm ]; then
			exec /usr/X11R6/bin/xterm -e /bin/sh -c "echo \"$HELP\" ; read"
		elif [ -x /usr/X11R6/bin/rxvt ]; then
			exec /usr/X11R6/bin/rxvt -e /bin/sh -c "echo \"$HELP\" ; read"
		fi
	fi
	echo $HELP
	;;
esac
