summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbuff-di-wuff15
1 files changed, 15 insertions, 0 deletions
diff --git a/buff-di-wuff b/buff-di-wuff
index 2be2f21..7a07d9d 100755
--- a/buff-di-wuff
+++ b/buff-di-wuff
@@ -2,6 +2,21 @@
set -e
+pid_file="/tmp/${0##*/}.pid"
+if [ -f "${pid_file}" ] \
+&& kill -0 "$(cat "${pid_file}")" >/dev/null 2>&1; then
+ >&2 printf 'another %s is running as %s\n' "${0##*/}" "$(cat "${pid_file}")"
+ exit
+fi
+
+echo $$ \
+> "${pid_file}"
+trap 'rm "${pid_file}"' EXIT
+
+if ! tty -s; then
+ sleep $((${RANDOM} % 3600))
+fi
+
cache_dir=$(readlink -e "$(dirname "$0")/../httpdocs")
mkdir -p \