commit 87bca2a234864e32dafe88ad84f18814d5e338c7
Author: Nicolas Chauvet <kwizart(a)gmail.com>
Date: Wed Jul 31 10:51:50 2019 +0200
fixup
roles/base/files/common-scripts/lock-wrapper | 15 +++++++++++----
1 files changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/roles/base/files/common-scripts/lock-wrapper
b/roles/base/files/common-scripts/lock-wrapper
index f990f63..abec9f3 100755
--- a/roles/base/files/common-scripts/lock-wrapper
+++ b/roles/base/files/common-scripts/lock-wrapper
@@ -8,6 +8,11 @@ fi
NAME=$1
SCRIPT=$2
+SILENT="no"
+if [ $# -ge 3 -a "$3" == "--silent" ]; then
+ SILENT="yes"
+fi
+
LOCKDIR="/var/tmp/$NAME"
PIDFILE="$LOCKDIR/pid"
@@ -17,13 +22,15 @@ function cleanup {
RESTORE_UMASK=$(umask -p)
umask 0077
-if ! mkdir "$LOCKDIR"; then
- echo "$LOCKDIR already exists"
+mkdir "$LOCKDIR" >& /dev/null
+if [ $? != 0 ]; then
PID=$(cat "$PIDFILE")
if [ -n "$PID" ] && /bin/ps $PID > /dev/null
then
- echo "$PID is still running"
- /bin/ps -o user,pid,start,time,comm $PID
+ if [ "$SILENT" != "yes" ]; then
+ echo "$PID is still running"
+ /bin/ps -o user,pid,start,time,comm $PID
+ fi
exit 1;
else
echo "$LOCKDIR exists but $PID is dead"
Show replies by date