aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/beam/common.in50
-rwxr-xr-xlib/beam/ldap.sh2
2 files changed, 40 insertions, 12 deletions
diff --git a/lib/beam/common.in b/lib/beam/common.in
index bc724c7..4d6442f 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
- pid=$(head -n 1 $backup_pidfile)
- if [ -z "$pid" ]; then
- abend 1 "pidfile $backup_pidfile exists but is unreadable or empty"
- fi
- abend 1 "another beam process (pid $pid) is still running; exiting"
+ 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 "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
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
@@ -186,6 +197,19 @@ dry_mail() {
echo "============================================================="
}
+# construct_mail_header NAME VALUE
+construct_mail_header() {
+ local name value
+ name=$(echo "mail_header_$1"|tr 'A-Z' 'a-z'|tr '-' '_')
+ value=$(echo "$1: $2" |\
+ tr '\n' ' ' |\
+ tr '\t' ' ' |\
+ tr -s ' ' |\
+ fmt -w64 -s |\
+ sed -e '2,$s/^/ /')
+ eval $name='$value'
+}
+
# mail_report FILE
mail_report() {
: ${backup_mailer_program:=/usr/sbin/sendmail -oi -t -F $backup_sender_email}
@@ -212,11 +236,15 @@ mail_report() {
fi
test -n "$backup_report_signature" &&
echo "$backup_report_signature" >> $report
- (cat - <<EOF
-From: ${backup_sender_personal}$backup_sender_email
-To: $backup_notify_email
-Subject: $backup_report_subject
-X-Beam-Items: $backup_items
+ (construct_mail_header From "${backup_sender_personal}$backup_sender_email"
+ construct_mail_header To "$backup_notify_email"
+ construct_mail_header Subject "$backup_report_subject"
+ construct_mail_header X-Beam-Items "$backup_items"
+ cat - <<EOF
+$mail_header_from
+$mail_header_to
+$mail_header_subject
+$mail_header_x_beam_items
X-Beam-Round: $round
X-Beam-Level: $level
EOF
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\"

Return to:

Send suggestions and report system problems to the System administrator.