#! /bin/sh

# A way to acquire a lock named $1 that works across the network on most
# systems; on System V, you should either set LN to /etc/link, or change
# the default below.

OLDLS=""; EQUAL=0;

until touch $1.x; ${LN=ln} $1.x $1 2> /dev/null
do
  LS="`ls -l $1 2> /dev/null`"
  if test "$OLDLS" = "$LS"
  then
    EQUAL=`expr $EQUAL + 1`
    if test $EQUAL -ge 30
    then
      rm -f $1; OLDLS=""; EQUAL=0
    fi
  else
    OLDLS="$LS"; EQUAL=0
  fi
  sleep 30
done
rm -f $1.x
