dsmcad
#!/bin/sh
### BEGIN INIT INFO
# Provides: skeleton
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: dsmcad initscript
# Description: Starts and stops ISP client acceptor daemon (CAD)
### END INIT INFO
#
# 21.02.2013
# Update : 05.05.2015
# neu: export LC_CTYPE=...
# Update : 16.12.2016
# neu: Variable INSTRLOG_FUER_DSMCAD,
# dsmcad-Aufrufe um Variable INSTRLOG_FUER_DSMCAD ergaenzt
# Update : 13.12.2017
# Ort der Log-Dateien
# Update : 25.05.2018
# weitere Kommentare
# Sprachumgebung fuer den ISP Client-Akzeptor
# -------------------------------------------
# Angaben fuer LANG und LC_CTYPE ggfls. anpassen
#
export LANG=en_US
export LC_CTYPE=en_US
# Ort der Log-Dateien fuer den ISP Client-Akzeptor/ISP Client-Scheduler
# ---------------------------------------------------------------------
# Angaben fuer errorlogname und instrlogname ggfls. anpassen
# - dsmerror.log: Fehlermeldungen des ISP Schedulers
# - dsminstr.log: Instrumentierungsprotokolldatei
# - dsmsched.log: Meldungen des ISP Schedulers
# - dsmwebcl.log: Meldungen des ISP Client Akzeptors (CAD)
#
# Option 'errorlogname' legt Ort fest fuer dsmerror.log, dsmwebcl.log
# Wenn Option 'schedlogname' nicht gesetzt, auch fuer dsmsched.log
# Option 'instrlogname' legt Ort fest fuer dsminstr.log
#
# Fehlende Verzeichnisse werden angelegt.
LOG_DATEIEN_PFAD="/usr/local/tsm/log"
ERRORLOG_FUER_DSMCAD="${LOG_DATEIEN_PFAD}/dsmerror.log"
INSTRLOG_FUER_DSMCAD="${LOG_DATEIEN_PFAD}/dsminstr.log"
mkdir -p ${LOG_DATEIEN_PFAD} >/dev/null 2>/dev/null
# Ort und Name des ISP Client-Akzeptors bzw. CLI (Scheduler)
# ----------------------------------------------------------
DSM_DIR="/usr/bin"
cad_name="dsmcad"
cli_name="dsmc"
daemon="${DSM_DIR}/${cad_name}"
scheduler="${DSM_DIR}/${cli_name}"
init_script_name="${cad_name}"
# Existenzpruefungen
# ------------------
[ -f ${scheduler} ] || exit 0
[ -f ${daemon} ] || exit 0
# Script beenden, wenn dsmcad aus /etc/inetd.conf gestartet wird
# --------------------------------------------------------------
if [ -f /etc/inetd.conf ] && grep "${cad_name}" /etc/inetd.conf >/dev/null 2>/dev/null
then
exit 0
fi
var_run_pid="/var/run/${cad_name}.pid"
case "$1" in
status) echo -n "Status Tivoli CAD: "
start-stop-daemon --start \
--pidfile ${var_run_pid} \
--make-pidfile \
--test \
--startas ${daemon} -- -errorlogname=${ERRORLOG_FUER_DSMCAD} \
-instrlogname=${INSTRLOG_FUER_DSMCAD}
if [ $? -eq 1 ]
then
echo "PID:`cat ${var_run_pid}`"
fi
echo "${init_script_name}."
;;
start) echo -n "Starting Tivoli CAD: "
start-stop-daemon --start \
--pidfile ${var_run_pid} \
--make-pidfile \
--startas ${daemon} -- -errorlogname=${ERRORLOG_FUER_DSMCAD} \
-instrlogname=${INSTRLOG_FUER_DSMCAD}
pid=$(pidof -x ${daemon})
if [ "${pid}" != "" ]
then
echo ${pid} > ${var_run_pid}
else
rm ${var_run_pid}
fi
echo "${init_script_name}."
;;
stop) echo -n "Stopping Tivoli CAD: "
start-stop-daemon --stop \
--pidfile ${var_run_pid} \
--oknodo \
--retry 30
if [ -f ${var_run_pid} ]
then
rm ${var_run_pid}
fi
echo "${init_script_name}."
;;
restart) echo -n "Restarting Tivoli CAD: "
start-stop-daemon --stop \
--pidfile ${var_run_pid} \
--oknodo \
--retry 30
if [ -f ${var_run_pid} ]
then
rm ${var_run_pid}
fi
start-stop-daemon --start \
--pidfile ${var_run_pid} \
--make-pidfile \
--startas ${daemon} -- -errorlogname=${ERRORLOG_FUER_DSMCAD} \
-instrlogname=${INSTRLOG_FUER_DSMCAD}
pid=$(pidof -x ${daemon})
if [ "${pid}" != "" ]
then
echo ${pid} > ${var_run_pid}
else
rm ${var_run_pid}
fi
echo "${init_script_name}."
;;
*) echo "Usage: /etc/init.d/${init_script_name} {start|stop|restart|status}"
exit 1
;;
esac
exit 0