diff options
author | Erich Eckner <git@eckner.net> | 2020-10-19 13:31:47 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2020-10-19 13:31:47 +0200 |
commit | 932ff6ef88e644634314135b15bfb905f121c5c5 (patch) | |
tree | 320aca012de2fd59cfa7e50b9fb2d08b6410ad68 | |
parent | b316b5d643cab62f35742ab9868e738561556f24 (diff) | |
download | buff-di-wuff-master.tar.xz |
-rwxr-xr-x | buff-di-wuff | 15 |
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 \ |