#!/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 ""View ${l_mesg}"" echo ""View older ${l_mesg}"" idx=$((${idx} + 1)) done } >> /var/install/menu/setup.services.proftpd.logfileview.menu } # --------------------------------------------------------------------------- # create logfile view header # --------------------------------------------------------------------------- create_logfile_view_menu_header() { { echo "Logfile view" echo "proftpd" echo "" echo "" } > /var/install/menu/setup.services.proftpd.logfileview.menu chmod 0644 /var/install/menu/setup.services.proftpd.logfileview.menu } # --------------------------------------------------------------------------- # create sub logfile menu # --------------------------------------------------------------------------- create_sub_logfile_view_menu() { # don't use filename for menu names but use a sub#### idx=1 for l_file in ${show_target} do l_dir=$( dirname "${l_file}" ) l_mesg=$( basename "${l_file}" ) fields=$( expr 1 + $( echo ${l_mesg} | awk -F. '{ print NF }' )) l_file=$( echo "${l_mesg}" | sed 's#\*#\\\*#g' ) logfiles=$( find ${l_dir} -maxdepth 1 -name "${l_file}.*" | sort -t. -n -k${fields} ) logfiles=$( echo "${logfiles}" | sed 's#\*#\\\*#g' ) { # remove mask l_mesg=$(echo "${l_mesg}" | sed 's#\\##g') l_mesg=$(echo "${l_mesg}" | sed 's#\\##g') echo "Logfile ${l_mesg} view" echo "proftpd" echo "" echo "" for t_file in ${logfiles} do t_mesg=$(basename "${t_file}") # don't mask * #t_file=$(echo "${t_file}" | sed 's#\*#\\\*#g') # remove mask t_file=$(echo "${t_file}" | sed 's#\\##g') # remove mask t_mesg=$(echo "${t_mesg}" | sed 's#\\##g') echo ""View ${t_mesg}"" done } > /var/install/menu/setup.services.proftpd.logfileview.sub${idx}.menu chmod 0644 /var/install/menu/setup.services.proftpd.logfileview.sub${idx}.menu idx=$((${idx} + 1)) done } # --------------------------------------------------------------------------- # main # --------------------------------------------------------------------------- if [ "${START_PROFTPD}" = "yes" ] then get_logfile_entry create_logfile_view_menu_header create_logfile_view_menu create_sub_logfile_view_menu else create_logfile_view_menu_header mecho mecho --warn "START_PROFTPD => no" mecho anykey fi # --------------------------------------------------------------------------- # end # ---------------------------------------------------------------------------