forked from extern/shorewall_code
Fix mkdir command in mutex_on()
- Also support 'lock' utility on openWRT Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
parent
3d4cde76aa
commit
7cce2e4ed5
@ -709,12 +709,15 @@ mutex_on()
|
|||||||
local lockf
|
local lockf
|
||||||
lockf=${LOCKFILE:=${VARDIR}/lock}
|
lockf=${LOCKFILE:=${VARDIR}/lock}
|
||||||
local lockpid
|
local lockpid
|
||||||
|
local lockd
|
||||||
|
|
||||||
MUTEX_TIMEOUT=${MUTEX_TIMEOUT:-60}
|
MUTEX_TIMEOUT=${MUTEX_TIMEOUT:-60}
|
||||||
|
|
||||||
if [ $MUTEX_TIMEOUT -gt 0 ]; then
|
if [ $MUTEX_TIMEOUT -gt 0 ]; then
|
||||||
|
|
||||||
[ -d ${VARDIR} ] || mkdir -p ${VARDIR}
|
lockd=$(dirname $LOCKFILE)
|
||||||
|
|
||||||
|
[ -d "$lockd" ] || mkdir -p "$lockd"
|
||||||
|
|
||||||
if [ -f $lockf ]; then
|
if [ -f $lockf ]; then
|
||||||
lockpid=`cat ${lockf} 2> /dev/null`
|
lockpid=`cat ${lockf} 2> /dev/null`
|
||||||
@ -734,6 +737,11 @@ mutex_on()
|
|||||||
chmod u+w ${lockf}
|
chmod u+w ${lockf}
|
||||||
echo $$ > ${lockf}
|
echo $$ > ${lockf}
|
||||||
chmod u-w ${lockf}
|
chmod u-w ${lockf}
|
||||||
|
elif qt mywhich lock; then
|
||||||
|
lock -${MUTEX_TIMEOUT} -r1 ${lockf}
|
||||||
|
chmod u+w ${lockf}
|
||||||
|
echo $$ > ${lockf}
|
||||||
|
chmod u-w ${lockf}
|
||||||
else
|
else
|
||||||
while [ -f ${lockf} -a ${try} -lt ${MUTEX_TIMEOUT} ] ; do
|
while [ -f ${lockf} -a ${try} -lt ${MUTEX_TIMEOUT} ] ; do
|
||||||
sleep 1
|
sleep 1
|
||||||
|
Loading…
Reference in New Issue
Block a user