summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--locale/en_US/pro_archman.sh3
-rw-r--r--src/pro-archman.sh12
2 files changed, 15 insertions, 0 deletions
diff --git a/locale/en_US/pro_archman.sh b/locale/en_US/pro_archman.sh
index 8636c72..f27cb84 100644
--- a/locale/en_US/pro_archman.sh
+++ b/locale/en_US/pro_archman.sh
@@ -17,6 +17,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# src/pro-archman.sh
+msg_pro_archman_lock_fail='The archive is locked by another process'
+
# lib/cmd.sh
msg_pro_archman_cmd_not_found='Command "%s" not found'
msg_pro_archman_cmd_usage='Usage: %s %s %s'
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 "${@}"