-replicate="/usr/local/etc/bin/zfs-replicate"
-logfile_parser="/usr/local/etc/bin/zfs-log-parser"
-logfile="/var/log/zfs-replicate.log"
-lockdir="/tmp/zfs-admin-lock"
-destpool="backups"
-maxsleeptime=60
-released_lock_date=0
-
-# Setup our cleanup and exit trap
-cleanup() {
+logfile="$logdir/zfs-replicate.log"
+mylogfile="$logdir/zfs-replicate-all.log"
+date=`date`
+starttime=`date +%s`
+
+# Make sure we aren't already running
+SCRIPT_NAME=${0##*/}
+PROCESS_LIST=`tempfile`
+ps -ef | grep -e "$SCRIPT_NAME" | grep -v grep | grep -v $$ | grep -v $PPID >> $PROCESS_LIST
+if [[ $? == 0 ]]; then
+ echo "$date Another $SCRIPT_NAME process is already running" >> $mylogfile
+ cat $PROCESS_LIST >> $mylogfile
+ exit 1
+fi
+[[ -e "$PROCESS_LIST" ]] && rm -f $PROCESS_LIST
+
+# This function checks to see if our runtime has exceeded our stoptime
+timeexceeded() {
+ if [[ $maxruntime == 0 ]]; then
+ return 0
+ fi
+ currenttime=`date +%s`
+ elapsedtime=$(($currenttime - $starttime))
+ stoptime=$(($maxruntime*60))
+ if [[ $elapsedtime -gt $stoptime ]]; then
+ #echo "$elapsedtime > $stoptime"
+ return 1
+ fi
+ #echo "$elapsedtime < $stoptime"
+ return 0
+}
+
+# This function cleanup and exit trap
+cleanup_and_exit() {
+ #echo "cleanup and exit"