You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
1.3 KiB
95 lines
1.3 KiB
#!/bin/bash
|
|
#
|
|
# please create the following directorys in the ROOTDIR
|
|
# in, process and backup
|
|
#
|
|
|
|
|
|
ROOTDIR=/tmp
|
|
PROCESSDIR=$ROOTDIR/process
|
|
LOCKFILE=$PROCESSDIR/checkfornewfiles.lock
|
|
INDIR=$ROOTDIR/in
|
|
BACKUPDIR=$ROOTDIR/backup
|
|
LOGFILE=$PROCESSDIR/debug.log
|
|
|
|
|
|
log () {
|
|
echo $1
|
|
echo $1 >> $LOGFILE
|
|
}
|
|
|
|
|
|
|
|
checkdir () {
|
|
if [ ! -d $1 ]; then
|
|
echo "`date` create dir $1"
|
|
mkdir $1
|
|
fi
|
|
}
|
|
|
|
|
|
log "`date` Startet"
|
|
checkdir $PROCESSDIR
|
|
checkdir $INDIR
|
|
checkdir $BACKUPDIR
|
|
|
|
|
|
|
|
#
|
|
# check for look file in indir
|
|
#
|
|
for f in $INDIR/*.lock
|
|
do
|
|
if [ -f $f ]; then
|
|
log "`date` found lockfile $f abort"
|
|
exit;
|
|
fi
|
|
done
|
|
|
|
|
|
#
|
|
# check for own lock file
|
|
#
|
|
if [ -f $LOCKFILE ]; then
|
|
log "`date` found lockfile $LOCKFILE abort"
|
|
exit;
|
|
fi
|
|
touch $LOCKFILE
|
|
|
|
#
|
|
# check for temp and import file
|
|
#
|
|
for f in $INDIR/*.import
|
|
do
|
|
if [ -f $f ]; then
|
|
log "`date` found temp file needed to rename and import ($(basename -- $f)"
|
|
FNAME=${f%.*}
|
|
if [ -f $FNAME.temp ]; then
|
|
mv $FNAME.temp $FNAME.evtx
|
|
fi;
|
|
rm -f $f
|
|
fi
|
|
done
|
|
|
|
|
|
|
|
#
|
|
# check for evtx files to import
|
|
#
|
|
for f in $INDIR/*.evtx
|
|
do
|
|
if [ -f $f ]; then
|
|
FNAME=$(basename -- $f)
|
|
log "`date` found evtx file needed to import ($FNAME)"
|
|
mv $f $PROCESSDIR/
|
|
evtx2sql-import.sh $PROCESSDIR/$FNAME
|
|
mv $PROCESSDIR/$FNAME $BACKUPDIR/
|
|
fi
|
|
done
|
|
|
|
|
|
|
|
rm $LOCKFILE
|
|
|
|
|