#!/bin/sh
#
### BEGIN INIT INFO
# Provides:          xfstt
# Required-Start:    $local_fs $network $remote_fs
# Required-Stop:     $local_fs $network $remote_fs
# Should-Start:
# Should-Stop:
# X-Start-Before:    gdm kdm xdm ldm sdm
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: xfstt sysv init script
# Description:       xfstt is a TrueType font server for X
### END INIT INFO
#
# Written by
# Stephen Carpenter <sjc@debian.org>,
# Gergely Egervary <mauzi@lin.lkg.c3.hu> and
# Guillem Jover <guillem@debian.org>.
#

set -e

PATH=/bin:/usr/bin:/sbin:/usr/sbin
NAME=xfstt
DAEMON=/usr/bin/$NAME
DESC="X font server"
PIDFILE=/var/run/$NAME.pid
CONFIGFILE=/etc/default/$NAME

# To change the default port and/or user modify and uncomment
portno=7101
newuser=nobody
#portarg="--port $portno"
#userarg="--user $newuser"

daemon="--daemon"

ARGS="$daemon $portarg $userarg"

test -x "$DAEMON" || exit 0

if [ -e $CONFIGFILE ]; then
	. $CONFIGFILE
else
	LISTEN_TCP=no
fi

if [ "$LISTEN_TCP" = no ]; then
	ARGS="$ARGS --notcp"
fi

. /lib/lsb/init-functions

set +e

case "$1" in
    start)
	log_daemon_msg "Starting $DESC" "$NAME"
	start-stop-daemon --start --quiet --pidfile $PIDFILE \
	                  --exec $DAEMON -- $ARGS
	log_end_msg $?
    ;;

    stop)
	log_daemon_msg "Stopping $DESC" "$NAME"
	start-stop-daemon --stop --quiet --pidfile $PIDFILE \
	                  --exec $DAEMON
	log_end_msg $?
    ;;

    force-reload|restart)
	$0 stop
	log_action_begin_msg "Reloading $DESC configuration"
	$DAEMON --sync >/dev/null
	log_action_end_msg $?
	$0 start
    ;;

  status)
	status_of_proc $DAEMON $NAME
	exit $?
	;;

    *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|force-reload|restart|status}"
	exit 1
    ;;
esac

exit 0

# vim: syn=sh:

