File suse.de-icinga of Package icinga.33763

#!/bin/sh
#
# Compress old logfiles in /var/log/icinga/archives/
# once a week, if sysconfig variable is set to true
#
CFG='/etc/icinga/icinga.cfg'
SYSCFG='/etc/sysconfig/icinga'

if [[ -r $SYSCFG ]]; then
. $SYSCFG
else
    echo "$SYSCFG not found or not readable." >&2
    exit 1
fi 

if [[ -r $CFG ]]; then
    ICINGA_USER=$( grep ^icinga_user  $CFG | tail -n 1 | sed 's@.*=@@' | tr -d '[:cntrl:]')
    ICINGA_GROUP=$(grep ^icinga_group $CFG | tail -n 1 | sed 's@.*=@@' | tr -d '[:cntrl:]')
fi

if [ -z "$ICINGA_USER" ]; then
    ICINGA_USER='__ICINGA_USER__'
fi
if [ -z "$ICINGA_GROUP" ]; then
    ICINGA_GROUP='__ICINGA_GROUP__'
fi

if [ "$ICINGA_COMPRESS_LOGFILES" = "true" ]; then
	for f in /var/log/icinga/archives/*.log ; do
        if [[ -r "$f" ]] ; then
            setpriv --init-groups --ruid $ICINGA_USER --rgid $ICINGA_GROUP --inh-caps -all --reset-env /usr/bin/bzip2 "$f"
        fi
    done
fi
openSUSE Build Service is sponsored by