#!/bin/sh

[[ ${#} = 1 ]] || exit 42

SAMHAIN_DB='samhain'
SAMHAIN_SRV='localhost'
SAMHAIN_PRT='3306'
SAMHAIN_USR='samhain'
SAMHAIN_PWD='*******'


mysql -u ${SAMHAIN_USR} --password=${SAMHAIN_PWD} ${SAMHAIN_DB} \
	-P ${SAMHAIN_PRT} -h ${SAMHAIN_SRV} \
	-e 'select count(*) from log where log_host="'${1}'";'  || \
( echo "SELECT FAILED" && exit 42 )

mysql -u ${SAMHAIN_USR} --password=${SAMHAIN_PWD} ${SAMHAIN_DB} \
	-P ${SAMHAIN_PRT} -h ${SAMHAIN_SRV} \
	-e 'delete from log where log_host="'${1}'";' || \
( echo "CLEANUP FAILED" && exit 42 )

