diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2018-05-11 11:43:34 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2018-05-11 11:43:34 +0200 |
commit | 66f06e2daeb2952a5dba017f03606b48c3ce4dec (patch) | |
tree | 45d68abacd61c7bab0be4d729f8655966d896bed | |
parent | aa48c0113be59350159788f9efd43d8736e87dcb (diff) | |
download | beam-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.in | 17 | ||||
-rwxr-xr-x | lib/beam/ldap.sh | 2 |
2 files changed, 15 insertions, 4 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() { ec=$1 shift error $@ + beam_unlock exit $ec } beam_lock() { if [ -r $backup_pidfile ]; then + if [ ! -r $PIDFILE ]; then + abend 1 "another beam is probably running: $backup_pidfile exists, but is not readable" + else pid=$(head -n 1 $backup_pidfile) if [ -z "$pid" ]; then - abend 1 "pidfile $backup_pidfile exists but is unreadable or empty" + abend 1 "failed to read PID from $backup_pidfile" + else + if kill -0 $pid 2>/dev/null; then + abend 1 "another beam (pid $pid) is still running; exiting" + else + error "removing stale pidfile $backup_pidfile" + rm $backup_pidfile || abend 1 "failed to remove stale pidfile $backup_pidfile" + fi + fi fi - abend 1 "another beam process (pid $pid) is still running; exiting" fi echo $$ > $backup_pidfile || exit 1 epilogue_hook="$epilogue_hook beam_unlock" + trap 'beam_unlock' INT QUIT TERM } beam_unlock() { @@ -153,7 +165,6 @@ beam_exec() { runhook() { local hook_list - eval hook_list=\$$1 for hook in $hook_list 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() { if [ -n "$dbno" ]; then options="$options -n$dbnum" elif [ -n "$dbsuf" ]; then - options="$options -b$slapcat" + options="$options -b$dbsuf" fi eval uri=\"\$${1}_uri\" |