#!/bin/sh # # mgcss MaGic Communication Server for Suse # # functions start the magic communication server # # version /etc/rc.d/init.d/mgcss 0.2 (pre.alpha) 03.10.2000 # to be used with SuSE # # author klaus-dieter uhlich, kladde # # mailing list: www.egroups.com/groups/magicu-l # # CS_PATH: directory of communication server # default is "/usr/magicadm/servers" CS_PATH=/usr/magicadm/servers # CS_USER: get the environment of an user # default is "magicadm" CS_USER=magicadm # CS_PORT: port number of communication server # default is "2060" CS_PORT=2060 # # source function library . /etc/rc.config # # Set the variable START_MGDATASRV = "yes" in /etc/rc.config file # to start the Communication Server on runtime level change. # # Determine the base and follow a runlevel link name. base=${0##*/} link=${base#*[SK][0-9][0-9]} # test $link = $base && START_MGDATASRV=yes test "$START_MGDATASRV" = "yes" || exit 0 # # set additional messages based on rc.config # to give more information. # if test "$TERM" != "raw" ; then rc_up="${stat}${attn}${extd} up${norm}" rc_down="${stat}${attn}${extd}down${norm}" else rc_up=" up" rc_down=" down" fi # # if you are not $CS_USER recall this script with $CS_USER. # if [ "$USER" != "$CS_USER" ] ; then su $CS_USER -c "umask 022; $0 $1" exit $? fi # # test the enviroment variables # if [ ! -f $CS_PATH/mgdispatch ] ; then echo "mgcss: $CS_PATH/mgdispatch not found$rc_failed" exit 1 fi # if [ ! -f $MAGIC_HOME/etc/mgpasswd ]; then echo "mgcss: $MAGIC_HOME/etc/mgpasswd not found$rc_failed" exit 2 fi # # # # See how we were called. # # echo -n "mgcss service $1:" case "$1" in start) checkproc $CS_PATH/mgdispatch && return=$rc_up || return=$rc_failed if [ "$return" == "$rc_failed" ] ; then cd $CS_PATH $CS_PATH/mgdispatch -$CS_PORT &> $CS_PATH/mgdispatch.log.$$ & checkproc $CS_PATH/mgdispatch && return=$rc_done || return=$rc_failed fi echo -e $return ;; stop) checkproc $CS_PATH/mgdispatch && return=$rc_done || return=$rc_down if [ "$return" == "$rc_done" ] ; then killproc -TERM $CS_PATH/mgdispatch && return=$rc_done || return=$rc_failed checkproc $CS_PATH/mgdatasrvr && dsrv=$rc_done || dsrv=$rc_down if [ "$dsrv" == "$rc_done" ] ; then killproc -TERM $CS_PATH/mgdatasrvr fi fi echo -e $return ;; reload|restart) echo $0 stop $0 start ;; status) checkproc $CS_PATH/mgdispatch && return=$rc_up || return=$rc_down echo -e $return ;; *) echo echo "Usage: $0 {start|stop|restart|reload|status}" exit 1 esac test "$return" == "$rc_failed" && exit 1 exit 0