#!/bin/bash # # Init file for DIM archiving daemon # # chkconfig: - 90 04 #description: DIM archiving daemon # #processname: dimarchd #config: /etc/trd/dimarch.conf #source function library . /etc/rc.d/init.d/functions #for my working dir #prog : body # progname="dimarchd" prog=/usr/sbin/dimarchd lockfile=/var/lock/subsys/dimarchd #[ -f $conffile ] || exit $? TMUX="tmux -S /tmp/tmux-dimarchd" RETVAL=0 start() { echo -n $"Starting $progname: " #$prog && success || failure #RETVAL=$? #[ "$RETVAL" = 0 ] && touch "$lockfile" tmux new-session -d -s dimarchd '. /etc/profile.d/dim.sh ; /usr/sbin/dimarchd -D' echo return $RETVAL } stop() { echo -n $"Stopping $progname: " #if [ -n "`pidofproc $prog`" ]; then #killproc $prog # RETVAL=$? #else # failure $"Stopping $prog" #fi #[ $RETVAL -eq 0 ] && rm -f "$lockfile" tmux kill-session -t dimarchd echo return $RETVAL } status() { if tmux ls | grep dimarchd then echo "dimarchd is running" RETVAL=0 else echo "dimarchd is stopped" RETVAL=3 fi return $RETVAL } attach() { if tmux ls | grep dimarchd then tmux attach -t dimarchd RETVAL=0 else echo "ERROR: dimarchd is stopped" RETVAL=3 fi return $RETVAL } #See how we were called. case "$1" in start) start ;; stop) stop ;; status) status ;; attach) attach ;; restart) stop start ;; condrestart) if [ -f "$lockfile" ]; then stop start fi ;; *) echo $"Usage: $prog {start|stop|restart|condrestart|status|attach}" exit 1 esac exit $RETVAL