#!/bin/sh
# -*- fill-column:75; coding: utf-8-unix; mode: sh-*-
#
# /etc/init.d/tsmclient
#
### BEGIN INIT INFO
# Provides: TSMscheduler
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: TSM Client
# Description: Start the dsmc TSM client in sched mode
### END INIT INFO

DSMC_BIN=/usr/bin/dsmc
DSMC_OPT=sched
test -x $DSMC_BIN || { echo "$DSMC_BIN not installed";
    if [ "$1" = "stop" ];
    then 
        exit 0;
    else 
        exit 5;
    fi;
}
export DSM_CONFIG=/opt/tivoli/tsm/client/ba/bin/dsm.opt

. /etc/rc.status
# First reset status of this service
rc_reset

# Note:
# The TSM client for Linux doesn't really grok UTF-8, so we are telling it
# to use a single byte locale when starting the scheduler. Note: For
# recovery you'll have to use wildcards for "special" characters.

case "$1" in
    start)
        echo -n "Starting TSM client in SCHED mode "
        LC_ALL=""
        export LANG=en_US
        export LC_CTYPE=en_US
        /sbin/startproc $DSMC_BIN $DSMC_OPT >/dev/null
        rc_status -v
        ;;
    stop)
        echo -n "Shutting down TSM client "
        /sbin/killproc -TERM $DSMC_BIN >/dev/null
        rc_status -v
        ;;
    restart)
        $0 stop
        $0 start
        # remember status and be quiet
        rc_status
        ;;
    status)
        echo -n "Checking for TSM client service "
        /sbin/checkproc $DSMC_BIN
        rc_status -v
        ;;
    *)
        echo "Usage $0 {start|stop|status|restart}"
        exit 1
        ;;
esac
rc_exit

