$NetBSD: patch-ae,v 1.10 2015/01/02 09:14:16 fhajny Exp $

- Default locations.
- Make it work with NetBSD's flock(1).

--- ejabberdctl.template.orig	2014-07-22 16:42:49.000000000 +0100
+++ ejabberdctl.template	2014-08-21 20:17:35.000000000 +0100
@@ -67,10 +67,10 @@
     EJABBERD_CONFIG_PATH=$ETC_DIR/ejabberd.yml
 fi
 if [ "$LOGS_DIR" = "" ] ; then
-    LOGS_DIR={{localstatedir}}/log/ejabberd
+    LOGS_DIR=@EJABBERD_LOGDIR@
 fi
 if [ "$SPOOL_DIR" = "" ] ; then
-    SPOOL_DIR={{localstatedir}}/lib/ejabberd
+    SPOOL_DIR=@EJABBERD_DB@
 fi
 if [ "$EJABBERD_DOC_PATH" = "" ] ; then
     EJABBERD_DOC_PATH={{docdir}}
@@ -81,7 +81,7 @@
 fi
 if [ "{{release}}" != "true" ] ; then
     if [ "$EJABBERDDIR" = "" ] ; then
-        EJABBERDDIR={{libdir}}/ejabberd
+        EJABBERDDIR={{libdir}}/erlang/lib/@DISTNAME@
     fi
     if [ "$EJABBERD_EBIN_PATH" = "" ] ; then
         EJABBERD_EBIN_PATH=$EJABBERDDIR/ebin
@@ -281,7 +281,7 @@
     # using flock if available. Expects a linux-style
     # flock that can lock a file descriptor.
     MAXCONNID=100
-    CONNLOCKDIR={{localstatedir}}/lock/ejabberdctl
+    CONNLOCKDIR=@EJABBERD_PIDDIR@
     FLOCK='/usr/bin/flock'
     if [ ! -x "$FLOCK" ] || [ ! -d "$CONNLOCKDIR" ] ; then
         JOT='/usr/bin/jot'
@@ -308,7 +308,7 @@
             CTL_LOCKFILE="$CONNLOCKDIR/$CTL_CONN"
             (
                 exec 8>"$CTL_LOCKFILE"
-                if flock --nb 8; then
+                if flock -x -n 8; then
                     ctlexec $CTL_CONN $COMMAND
                     ssresult=$?
                     # segregate from possible flock exit(1)
