#!/bin/sh

# Written by Feline (feline@irendi.com) - Irendi Software
#
# All code distributed under the GNU Public Licence, version 2.
# Copyright Michael Sharpe 1994-2000.
#
# We grant permission to use, copy, modify, and distribute this software
# under the terms of the GPL v2, provided that the above copyright
# notice and this text are not removed. We make no guarantee about the
# sutability of this software for any purpose and we are not liable
# for any damages resulting from its use. Further, we are under no
# obligation to maintain or extend this software. It is provided on an
# "as is" basis without any express or implied warranty.
#
# Bug reports, enhancement requests and bug fixes are always welcome.

#
# This script starts or stops the autosig daemon. The daemon simply writes a
# new signature down the sigFile pipe every time the pipe is read.

sigFile=dotsignature
case "$1" in
start)
   quoteFile=quotes
   delimiter="~###~"
   sigHeader=dotsignc

   if [ -e $sigFile ]; then
      rm $sigFile
   fi

   autosig $quoteFile $delimiter $sigHeader $sigFile 1
   echo "Now cat $sigFile a few times"
;;
stop)
   userName=`whoami`
   pidFilename=/tmp/autosig-$userName.pid
   if [ -e $pidFilename ]; then
      kill `cat $pidFilename`
      rm $pidFilename
   fi

   if [ -e $sigFile ]; then
      rm $sigFile
   fi
   echo "autosig stopped"
;;
*)
   echo "$0 [start|stop]"
;;
esac
