#!/bin/sh
#----------------------------------------------------------------------------
# /var/install/bin/pre-setup-services-rsyslogd-logfileview-menu
#
# Creation: 2011-05-08 hbfl
# Last Update: $Id$
#
# Copyright (c) 2011-2022 the eisfair team, team(at)eisfair(dot)org
#
# Original: pre-setup-system-logfileview-menu
# Modified for rsyslogs package
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#----------------------------------------------------------------------------
. /var/install/include/eislib
. /etc/config.d/rsyslogd
#exec 2>/tmp/$(basename ${0})-trace$$.log
#set -x
# ---------------------------------------------------------------------------
# get logfile compression extension from compresscmd in /etc/logrotate.conf
# ---------------------------------------------------------------------------
get_logfile_comp_extension ()
{
# compresscmd including path
compresscmd=$(grep ^compresscmd /etc/logrotate.conf | cut -f2 -d' ')
# strip path
compresscmd=$(echo $compresscmd | sed "s/.*\///")
case "$compresscmd" in
'xz') # xz compression
comp_extension='xz'
;;
'') # default gzip
comp_extension='gz'
;;
*) # unknown
;;
esac
}
# ---------------------------------------------------------------------------
# get logfile target from rsyslogd config file
# ---------------------------------------------------------------------------
get_logfile_entry ()
{
show_target=''
dyna_file_actions=''
# build target list in $show_target
idx=1
while [ ${idx} -le ${RSYSLOGD_RULE_N} ]
do
eval active='${RSYSLOGD_RULE_'${idx}'_ACTIVE}'
if [ "${active}" = "yes" ]
then
eval target='${RSYSLOGD_RULE_'${idx}'_ACTION}'
# check actions default is 'false'
is_file='false'
is_dynafile='false'
act_char_1=${target:0:1}
act_char_1to2=${target:0:2}
case "${act_char_1}" in
'|') # | named pipe
true
;;
'@') # remote host
true
;;
'~') # discard
true
;;
'-') # -/ => file or -? => dynafile
if [ "$act_char_1to2" = '-?' ]
then
# dynafile
is_dynafile='true'
else
# file
# strip - sign
target=${target:1}
is_file='true'
fi
true
;;
'/') # / => file
# check /dev/ later
is_file='true'
true
;;
'?') # ? => dynafile
is_dynafile='true'
true
;;
'>') # database
true
;;
'^') # shell execute
true
;;
*) # user list
;;
esac
if [ ${is_dynafile} = 'true' ]
then
if [ -z "${dyna_file_actions}" ]
then
dyna_file_actions="$idx"
else
dyna_file_actions="${dyna_file_actions} $idx"
fi
fi
if [ ${is_file} = 'true' ]
then
# check for devices like /dev/console
if echo "${target}" | grep -qv '^/dev/'
then
if [ -z "${show_target}" ]
then
show_target="${target}"
else
show_target="${show_target} ${target}"
fi
fi
fi
fi
idx=$(/usr/bin/expr ${idx} + 1 )
done
echo "dyna_file_actions=$dyna_file_actions" > /tmp/apapap
}
# ---------------------------------------------------------------------------
# create logfile view entry
# ---------------------------------------------------------------------------
create_logfile_view_menu ()
{
# don't use filename for menu names but use a sub####
idx=1
{
for l_file in ${show_target}
do
l_mesg=$(basename "${l_file}")
# don't mask *
#l_file=$(echo "${l_file}" | sed 's#\*#\\\*#g')
# remove mask
l_mesg=$(echo "${l_mesg}" | sed 's#\\##g')
echo "