Archived
1
0
Fork 0
This repository has been archived on 2021-10-08. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
ACU/process/view_log.sh
2013-09-28 18:39:15 +02:00

71 lines
1,020 B
Bash
Executable file

#! /bin/sh
cd `dirname $0`/..
UN=$1
if [ "$1" = "clean" ]
then
CMD=rm
shift
elif [ "$1" = "full" ]
then
CMD=cat
shift
elif echo "$1" | grep -e '^-' > /dev/null
then
CMD="tail -n `echo $1 | cut -d '-' -f 2-`"
shift
else
CMD="tail -n 50"
fi
TMP=`mktemp`
DIRS="./"
if [ -d "/var/log/hooks/" ]
then
DIRS="$DIRS /var/log/hooks/"
fi
if [ $# -eq 0 ]
then
for D in $DIRS
do
for I in `find "$D" -name '*.log'`
do
/bin/echo -e "`dirname ${I#$D}`/\e[1m`basename $I`\e[0m"
done
done
else
LIST=`mktemp`
find $DIRS -name '*.log' > $LIST
while [ $# -gt 0 ]
do
NB=`grep "/$1" "$LIST" | wc -l`
if [ $NB = 1 ]
then
$CMD `grep "/$1" "$LIST"`
echo
elif [ $NB -gt 1 ]
then
echo "Too much matching file for '$1':"
for I in `grep "$1" "$LIST" | sed -E 's#^./##'`
do
/bin/echo -e "`dirname $I`/\e[1m`basename $I`\e[0m"
done
else
echo "Unable to find '$1' log file"
exit 1
fi
shift
done
rm -rf "$LIST";
fi