Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP3:GA
drbd-utils.5899
Support-logfacility-local5.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File Support-logfacility-local5.patch of Package drbd-utils.5899
commit 8d7e83832fd95d1bedd867827cfd6daf6f91e2d4 Author: Nick Wang <nwang@suse.com> Date: Tue Nov 7 16:43:05 2017 +0800 drbd-utils: Remove the hardcoded local5 of logfacility It is able to override the loglevel with --logfacility in crm-fence-peer.sh. However, in other scripts still hardcoded to "local5.info". It is confusing only redirect part of scripts. Support --logfacility in notify.sh and snapshot-resync-target-lvm.sh diff --git a/scripts/notify.sh b/scripts/notify.sh index c7bfb9c1..71cdbb7d 100755 --- a/scripts/notify.sh +++ b/scripts/notify.sh @@ -7,15 +7,54 @@ # try to get possible output on stdout/err to syslog PROG=${0##*/} -# Funky redirection to avoid logger feeding its own output to itself accidentally. -# Funky double exec to avoid an intermediate sub-shell. -# Sometimes, the sub-shell lingers around, keeps file descriptors open, -# and logger then won't notice the main script has finished, -# forever waiting for further input. -# The second exec replaces the subshell, and logger will notice directly -# when its stdin is closed once the main script exits. -# This avoids the spurious logger processes. -exec > >( exec 1>&- 2>&- logger -t "$PROG[$$]" -p local5.info) 2>&1 +redirect_to_logger() +{ + local lf=${1:-local5} + case $lf in + # do we want to exclude some? + auth|authpriv|cron|daemon|ftp|kern|lpr|mail|news|syslog|user|uucp|local[0-7]) + : OK ;; + *) + echo >&2 "invalid logfacility: $lf" + return + ;; + esac + + # Funky redirection to avoid logger feeding its own output to itself accidentally. + # Funky double exec to avoid an intermediate sub-shell. + # Sometimes, the sub-shell lingers around, keeps file descriptors open, + # and logger then won't notice the main script has finished, + # forever waiting for further input. + # The second exec replaces the subshell, and logger will notice directly + # when its stdin is closed once the main script exits. + # This avoids the spurious logger processes. + exec > >( exec 1>&- 2>&- logger -t "$PROG[$$]" -p $lf.info ) 2>&1 +} + +if [[ $- != *x* ]]; then + # you may override with --logfacility below + redirect_to_logger local5 +fi + +TEMP=$(getopt -o l: --long logfacility: -- "$@") +eval set -- "$TEMP" +while [[ $# != 0 ]]; do + case $1 in + -l|--logfacility) + redirect_to_logger $2 + shift + ;; + --) + ;; + *) + RECIPIENT=${1:-root} + ;; + esac + shift +done + +# Default to sending email to root, unless otherwise specified +: ${RECIPIENT:=root} if [[ $DRBD_VOLUME ]]; then pretty_print="$DRBD_RESOURCE/$DRBD_VOLUME (drbd$DRBD_MINOR)" @@ -25,9 +64,6 @@ fi echo "invoked for $pretty_print" -# Default to sending email to root, unless otherwise specified -RECIPIENT=${1:-root} - # check arguments specified on command line if [ -z "$RECIPIENT" ]; then echo "You must specify a notification recipient when using this handler." >&2 diff --git a/scripts/snapshot-resync-target-lvm.sh b/scripts/snapshot-resync-target-lvm.sh index 8eec5d13..0e6b91a8 100755 --- a/scripts/snapshot-resync-target-lvm.sh +++ b/scripts/snapshot-resync-target-lvm.sh @@ -21,10 +21,31 @@ if [[ -z "$DRBD_RESOURCE" || -z "$DRBD_LL_DISK" ]]; then fi PROG=$(basename $0) -exec > >(exec 2>&- ; logger -t "$PROG[$$]" -p local5.info) 2>&1 + +redirect_to_logger() +{ + local lf=${1:-local5} + case $lf in + # do we want to exclude some? + auth|authpriv|cron|daemon|ftp|kern|lpr|mail|news|syslog|user|uucp|local[0-7]) + : OK ;; + *) + echo >&2 "invalid logfacility: $lf" + return + ;; + esac + + exec > >( exec 1>&- 2>&- logger -t "$PROG[$$]" -p $lf.info ) 2>&1 +} + +if [[ $- != *x* ]]; then + # you may override with --logfacility below + redirect_to_logger local5 +fi + echo "invoked for $DRBD_RESOURCE/$DRBD_VOLUME (drbd$DRBD_MINOR)" -TEMP=$(getopt -o p:a:nv --long percent:,additional:,disconnect-on-error,verbose -- "$@") +TEMP=$(getopt -o p:a:l:nv --long percent:,additional:,logfacility:,disconnect-on-error,verbose -- "$@") if [ $? != 0 ]; then echo "getopt failed" @@ -88,6 +109,10 @@ while true; do -v|--verbose) BE_VERBOSE=1 ;; + -l|--logfacility) + redirect_to_logger $2 + shift + ;; --) break ;;
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor