aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2018-05-11 11:43:34 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2018-05-11 11:43:34 +0200
commit66f06e2daeb2952a5dba017f03606b48c3ce4dec (patch)
tree45d68abacd61c7bab0be4d729f8655966d896bed
parentaa48c0113be59350159788f9efd43d8736e87dcb (diff)
downloadbeam-66f06e2daeb2952a5dba017f03606b48c3ce4dec.tar.gz
beam-66f06e2daeb2952a5dba017f03606b48c3ce4dec.tar.bz2
Bugfix
* lib/beam/common.in (abend): Call beam_unlock explicitly (beam_lock): Rewrite. * lib/beam/ldap.sh (ldap_backup): Fix the -b option argument.
-rw-r--r--lib/beam/common.in23
-rwxr-xr-xlib/beam/ldap.sh2
2 files changed, 18 insertions, 7 deletions
diff --git a/lib/beam/common.in b/lib/beam/common.in
index bc724c7..e8389f9 100644
--- a/lib/beam/common.in
+++ b/lib/beam/common.in
@@ -45,19 +45,31 @@ abend() {
45 ec=$1 45 ec=$1
46 shift 46 shift
47 error $@ 47 error $@
48 beam_unlock
48 exit $ec 49 exit $ec
49} 50}
50 51
51beam_lock() { 52beam_lock() {
52 if [ -r $backup_pidfile ]; then 53 if [ -r $backup_pidfile ]; then
53 pid=$(head -n 1 $backup_pidfile) 54 if [ ! -r $PIDFILE ]; then
54 if [ -z "$pid" ]; then 55 abend 1 "another beam is probably running: $backup_pidfile exists, but is not readable"
55 abend 1 "pidfile $backup_pidfile exists but is unreadable or empty" 56 else
56 fi 57 pid=$(head -n 1 $backup_pidfile)
57 abend 1 "another beam process (pid $pid) is still running; exiting" 58 if [ -z "$pid" ]; then
59 abend 1 "failed to read PID from $backup_pidfile"
60 else
61 if kill -0 $pid 2>/dev/null; then
62 abend 1 "another beam (pid $pid) is still running; exiting"
63 else
64 error "removing stale pidfile $backup_pidfile"
65 rm $backup_pidfile || abend 1 "failed to remove stale pidfile $backup_pidfile"
66 fi
67 fi
68 fi
58 fi 69 fi
59 echo $$ > $backup_pidfile || exit 1 70 echo $$ > $backup_pidfile || exit 1
60 epilogue_hook="$epilogue_hook beam_unlock" 71 epilogue_hook="$epilogue_hook beam_unlock"
72 trap 'beam_unlock' INT QUIT TERM
61} 73}
62 74
63beam_unlock() { 75beam_unlock() {
@@ -153,7 +165,6 @@ beam_exec() {
153 165
154runhook() { 166runhook() {
155 local hook_list 167 local hook_list
156
157 eval hook_list=\$$1 168 eval hook_list=\$$1
158 for hook in $hook_list 169 for hook in $hook_list
159 do 170 do
diff --git a/lib/beam/ldap.sh b/lib/beam/ldap.sh
index 40b9a4b..714b249 100755
--- a/lib/beam/ldap.sh
+++ b/lib/beam/ldap.sh
@@ -80,7 +80,7 @@ ldap_backup() {
80 if [ -n "$dbno" ]; then 80 if [ -n "$dbno" ]; then
81 options="$options -n$dbnum" 81 options="$options -n$dbnum"
82 elif [ -n "$dbsuf" ]; then 82 elif [ -n "$dbsuf" ]; then
83 options="$options -b$slapcat" 83 options="$options -b$dbsuf"
84 fi 84 fi
85 85
86 eval uri=\"\$${1}_uri\" 86 eval uri=\"\$${1}_uri\"

Return to:

Send suggestions and report system problems to the System administrator.