1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
#!/bin/sh
VAR=@localstatedir@
NOVAR=${prefix}/var
if [ x$VAR = x$NOVAR ]
then
VAR=@prefix@/var
fi
PID=$VAR/cachelogd.pid
SPLITTER=@prefix@/sbin/splitter
HUP=0
PRESPLIT=0
SPLIT=0
usage()
{
cat <<EOF
Usage: $0 [OPTIONS]
Options:
[-k] [--hup] Send -HUP signal to cachelogd
[-p] [--prepare] Prepare logs
[-s] [--split] Split logs
[-h] [--help] Display this page
Configuration:
Base dir: $VAR
Pid file: $PID
EOF
exit $1
}
rename_logs()
{
for LOG_NAME in `ls *.del`
do
mv $LOG_NAME $LOG_NAME.done
done
for LOG_NAME in `ls *.wrd`
do
mv $LOG_NAME $LOG_NAME.done
done
}
if test $# -eq 0; then
usage 1 1>&2
fi
while test $# -gt 0; do
case $1 in
-k)
HUP=1
;;
--hup)
HUP=1
;;
-p)
PRESPLIT=1
;;
--prepare)
PRESPLIT=1
;;
-s)
SPLIT=1
;;
--split)
SPLIT=1
;;
*)
usage 1 1>&2
;;
esac
shift
done
if [ x$HUP = x1 ]
then
echo "Sending -HUP signal to cachelogd..."
# Check whether cachelogd is running
if [ -s $PID ]
then
# Send HUP signal to cachelogd process
PROC=`cat $PID`
kill -HUP $PROC
# Check whether kill didn't fail
if [ x$? = x1 ]
then
echo "kill -HUP $PROC failed."
exit 1
fi
echo "Done"
else
echo "$PID is empty or doesn't exist!"
echo "Check that cachelogd is running."
exit 1
fi
fi
if [ x$PRESPLIT = x1 ]
then
# Presplit logs
echo "Preparing logs..."
$SPLITTER -p
echo "Renaming logs..."
cd $VAR/raw
rename_logs
echo "Done"
fi
if [ x$SPLIT = x1 ]
then
# Split logs
echo "Runnig splitter..."
$SPLITTER
echo "Deleting logs..."
cd $VAR/splitter
rm *.log
echo "Done"
fi
|