#! /bin/sh

PATH=/bin:/usr/bin:/sbin:/usr/sbin

GNUSTEP_SYSTEM_ROOT=/usr/lib/GNUstep/System
export GNUSTEP_SYSTEM_ROOT

DAEMON=/usr/lib/GNUstep/System/Tools/s390/linux-gnu/gdomap
PIDFILE=/var/run/gdomap.pid

GDOMAP_ARGS=
if [ -f /etc/default/gdomap ]; then
    . /etc/default/gdomap
fi

# The following value is extracted by debstd to figure out how to generate
# the postinst script. Edit the field to change the way the script is
# registered through update-rc.d (see the manpage for update-rc.d!)
FLAGS="defaults 50"

test -f $DAEMON || exit 0

case "$1" in
  start)
    echo -n "Starting GNUStep distributed object mapper: gdomap"
    start-stop-daemon --start --quiet --pid $PIDFILE --exec $DAEMON \
    	-- -I $PIDFILE $GDOMAP_ARGS
    echo "."
    ;;
  stop)
    echo -n "Stopping GNUStep distributed object mapper: gdomap"
    start-stop-daemon --stop --quiet --pid $PIDFILE \
    	-- -I $PIDFILE $GDOMAP_ARGS
    rm -f $PIDFILE
    echo "."
    ;;
  restart|reload|force-reload)
    /etc/init.d/gdomap stop
    /etc/init.d/gdomap start
    ;;
  *)
    echo "Usage: /etc/init.d/`basename $0` {start|stop|restart}"
    exit 1
    ;;
esac

exit 0
