diff options
author | P. J. McDermott <pjm@nac.net> | 2013-07-29 23:35:31 (EDT) |
---|---|---|
committer | P. J. McDermott <pjm@nac.net> | 2013-07-29 23:35:31 (EDT) |
commit | 0a432ebb8bc1137d76d297eb68b4daec5364c89e (patch) | |
tree | de87d63931796a41e105273ae97ba3254f564469 /src | |
parent | fb4283933ca23b47cb27b8fa51b1c1431b6df7dd (diff) |
pro-archman: Lock the archive.
Diffstat (limited to 'src')
-rw-r--r-- | src/pro-archman.sh | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/pro-archman.sh b/src/pro-archman.sh index 1f9628b..8b0719b 100644 --- a/src/pro-archman.sh +++ b/src/pro-archman.sh @@ -36,6 +36,7 @@ conf_incoming_channel= conf_incoming_dir= conf_pool_gc_delay= archive= +lock= # use() must be defined inline so it can be used to load other modules. use() @@ -100,6 +101,14 @@ main() # FIXME: Remove. archive="${opt_base_dir}" + mkdir -p "${opt_base_dir}/.db" + lock="${opt_base_dir}/.db/lock" + if ! (set -C; printf '%d\n' "${$}" >"${lock}") 2>/dev/null; then + printf '%s: Error: ' "${0##*/}" >&2 + printf "$(get_msg 'lock_fail')\n" >&2 + exit 2 + fi + if [ "x${opt_cmd}" != 'x' ]; then run_cmd "${opt_cmd}" "${@}" status=${?} @@ -159,5 +168,8 @@ fini() { update_feeds collect_garbage + + rm -f "${lock}" } + main "${@}" |