#!/bin/bash # # dsmcad Start up the TSM backup daemon # # chkconfig: 345 56 24 # description: TSM (Tivoli Storage Manager) is the backup system used \ # used at UiO. This service starts up the TSM backup \ # daemon (dsmcad). # # See https://fedoraproject.org/wiki/Packaging:SysVInitScript for # the guidelines document. # Source function library. . /etc/rc.d/init.d/functions # User options OPTFILE[0]="/etc/dsm.opt" NAME[0]="default" # Other variables exec="/opt/tivoli/tsm/client/ba/bin/dsmcad" base="uio-dsmcad" # Config file [ -e /etc/sysconfig/$base ] && . /etc/sysconfig/$base # Set some environment variables LANG=en_US LC_CTYPE=en_US DSM_DIR=/opt/tivoli/tsm/client/ba/bin/ DSM_LOG=/opt/tivoli/tsm/client/ba/bin/ export LANG LC_CTYPE DSM_DIR DSM_LOG function start() { [ -x $exec ] || exit 5 for i in $(seq 0 $((${#OPTFILE[@]} - 1))); do [ -f ${OPTFILE[$i]} ] || exit 6 DSM_CONFIG=${OPTFILE[$i]} export DSM_CONFIG echo -n $"Starting $base (${NAME[$i]}): " daemon $exec -optfile=${OPTFILE[$i]} retval=$? sleep 1 echo pidfile="/var/run/${base}_${NAME[$i]}.pid" # rather ugly, but it works ps -C dsmcad h | grep "optfile=${OPTFILE[$i]}" | awk '{print $1}' > $pidfile lockfile="/var/lock/subsys/${base}_${NAME[$i]}" [ $retval -eq 0 ] && touch ${lockfile} done return $retval } function stop() { for i in $(seq 0 $((${#OPTFILE[@]} - 1))); do pidfile="/var/run/${base}_${NAME[$i]}.pid" [ -f ${pidfile} ] || continue lockfile="/var/lock/subsys/${base}_${NAME[$i]}" echo -n $"Stopping $base (${NAME[$i]}): " killproc -p ${pidfile} dsmcad retval=$? echo [ $retval -eq 0 ] && rm -f ${lockfile} ${pidfile} # FIXME: bug cleanup (temporary) [ -f "/var/run/S56${base}_${NAME[$i]}.pid" ] \ && rm -f /var/run/S56${base}_${NAME[$i]}.pid [ -f "/var/lock/subsys/S56${base}_${NAME[$i]}" ] \ && rm -f /var/lock/subsys/S56${base}_${NAME[$i]} done killproc dsmcad >/dev/null return $retval } function restart() { stop start } function reload() { restart } function force_reload() { restart } function rh_status() { for i in $(seq 0 $((${#OPTFILE[@]} - 1))); do pidfile="/var/run/${base}_${NAME[$i]}.pid" length=$(echo ${NAME[$i]} | wc -c) echo -n "${NAME[$i]}" if [ $length -le 10 ]; then for j in $(seq 1 $((10 - $length))); do echo -n ' ' done fi echo -n ' : ' status -p ${pidfile} $base done } function rh_status_q() { rh_status >/dev/null 2>&1 } case "$1" in start) rh_status_q && exit 0 $1 ;; stop) rh_status_q || exit 0 $1 ;; restart) $1 ;; reload) rh_status_q || exit 7 $1 ;; force-reload) force_reload ;; status) rh_status ;; condrestart|try-restart) rh_status_q || exit 0 restart ;; *) echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" exit 2 esac exit $?