-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlock_ssh.sh
More file actions
executable file
·58 lines (43 loc) · 2.05 KB
/
Copy pathlock_ssh.sh
File metadata and controls
executable file
·58 lines (43 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env bash
#
# Copyright (c) 2013, Qualcomm Innovation Center, Inc. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
usage() { # error_message
local prog=$(basename -- "$0")
cat >&2 <<EOF
usage: $prog [opts][gopts] lock <lock_path> <pid>
$prog [opts] lock_check <lock_path> <pid>
$prog [opts][gopts] unlock <lock_path> <pid|uid>
$prog [opts] fast_lock <lock_path> <pid>
$prog [opts] owner <lock_path> > uid
$prog [opts] owner_pid <lock_path> > pid
$prog [opts] owner_hostid <lock_path> > hostid
$prog [opts] is_mine <lock_path> <pid|uid>
$prog is_host_compatible <sshdest|hostid>
A lock manager designed for cluster use via a shared filesystem with
ssh run checks.
gopts (grace options):
--grace-seconds <seconds>
seconds The amount of time a lock component needs to be untouched for
before even considering checking it for staleness. Checking
for staleness requires logging into the lock host via ssh.
To prevent multiple checkers, set this to longer then the worst
case check time. The longest potential stale recovery time is
the sum of the worst case check time and twice this delay.
The default is 10s.
opts (global options)
--on-check-fail notifier Specify a notifier to run a command when
it is not possible to determine
live/staleness. Args may be added by
using --on-check-notifier multiple times.
(Default notifier prints warnings to stderr)
The notifier should expect the following
trailing arguments:
<lock> <locking_host> <uid> <reason>
EOF
[ $# -gt 0 ] && echo "Error - $@" >&2
exit 10
}
MYPATH=$(readlink -e -- "$0")
MYDIR=$(dirname -- "$MYPATH")
"$MYDIR/lib/hostpid_lock.sh" --idhelper "$MYDIR/ssh_id.sh" "$@"