#!/usr/bin/sh
#----------------------------------------------------------------------------
# /var/install/bin/pre-setup-services-proftpd-logfileview-menu
#
# Creation: 2011-05-08 hbfl
# Last Update: $Id$
#
# Copyright (c) 2011-@@YEAR@@ the eisfair team, team(at)eisfair(dot)org
# Copyright (c) 2024-@@YEAR@@ Holger Bruenjes, holgerbruenjes(at)gmx(dot)net
#
# Original: pre-setup-system-logfileview-menu
# Modified for proftpd 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/base
. /etc/config.d/proftpd
FIXED_TLS_LOG='/var/log/proftpd/proftpd_tls.log'
proftpd_log_root='/var/log/proftpd/'
#exec 2> /tmp/server-logfile-trace$$
#set -x
# ---------------------------------------------------------------------------
# get logfile target from proftpd
# ---------------------------------------------------------------------------
get_logfile_entry()
{
show_target=''
# build target list in $show_target
if [ "$PROFTPD_SYSTEM_LOG" = 'NONE' -o "$PROFTPD_SYSTEM_LOG" = '' ]
then
true
else
target="$PROFTPD_SYSTEM_LOG"
first_char=$(echo $target | cut -c 1)
[ ! "$first_char" = '/' ] && target="$proftpd_log_root$target"
[ -z "${show_target}" ] && show_target="${target}" || show_target="${show_target} ${target}"
fi
if [ "$PROFTPD_TRANSFER_LOG" = 'NONE' ]
then
true
else
[ -z "$PROFTPD_TRANSFER_LOG" ] && target='/var/log/proftpd/xferlog' || target="$PROFTPD_TRANSFER_LOG"
first_char=$(echo $target | cut -c 1)
[ ! "$first_char" = '/' ] && target="$proftpd_log_root$target"
if [ -f "$target" ]
then
[ -z "${show_target}" ] && show_target="${target}" || show_target="${show_target} ${target}"
fi
fi
if [ -f "$FIXED_TLS_LOG" ]
then
target="$FIXED_TLS_LOG"
[ -z "${show_target}" ] && show_target="${target}" || show_target="${show_target} ${target}"
fi
#echo "Debug: show_target=$show_target"
}
# ---------------------------------------------------------------------------
# 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 "