#!/bin/sh

## FIXME! switch to %%PREFIX%%

umask 022
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:%%PREFIX%%/bin

if [ -x %%PREFIX%%/etc/snort/rules -a -x %%PREFIX%%/etc/snort/community -a -x %%PREFIX%%/etc/snort/ET ]; then

%%PREFIX%%/bin/oinkmaster.pl -o %%PREFIX%%/etc/snort/rules/ -b %%PREFIX%%/etc/snort/backup/ -C %%PREFIX%%/etc/oinkmaster.conf
#%%PREFIX%%/bin/oinkmaster.pl -o %%PREFIX%%/etc/snort/community/ -b %%PREFIX%%/etc/snort/backup.community/ -u https://www.snort.org/downloads/community/community-rules.tar.gz  -C %%PREFIX%%/etc/oinkmaster.conf
%%PREFIX%%/bin/oinkmaster.pl -o %%PREFIX%%/etc/snort/ET/ -b %%PREFIX%%/etc/snort/backup.ET/ -u http://rules.emergingthreats.net/open/snort-2.9.0/emerging.rules.tar.gz  -C %%PREFIX%%/etc/oinkmaster.conf

## See Q26, Q30 of oinkmaster FAQ: file needed by Barnyard and the like
%%PREFIX%%/share/examples/oinkmaster/contrib/create-sidmap.pl \
	%%PREFIX%%/etc/snort/rules/ \
	%%PREFIX%%/etc/snort/community/ \
	%%PREFIX%%/etc/snort/ET/ \
	> %%PREFIX%%/etc/snort/rules/sid-msg.map \
	2>/tmp/oinkmaster-create-sidmap_err.log

else

	echo "FATAL! missing some directories and/or permissions"

fi


