From 8a16cefc96a1e9389189b0a8f0bbe4bdb39b03ec Mon Sep 17 00:00:00 2001 From: thompsa Date: Thu, 28 Jan 2010 10:08:31 +1300 Subject: rename rc.d/snort to rc.d/snort.sh so it starts at boot. --- config/snort-dev/snort | 99 ----------------------- config/snort-dev/snort.sh | 99 +++++++++++++++++++++++ config/snort-dev/snort.xml | 2 +- config/snort-dev/snort_check_for_rule_updates.php | 2 +- config/snort-dev/snort_interfaces.php | 6 +- config/snort-dev/snort_interfaces_edit.php | 2 +- 6 files changed, 105 insertions(+), 105 deletions(-) delete mode 100755 config/snort-dev/snort create mode 100755 config/snort-dev/snort.sh diff --git a/config/snort-dev/snort b/config/snort-dev/snort deleted file mode 100755 index 5b725cfe..00000000 --- a/config/snort-dev/snort +++ /dev/null @@ -1,99 +0,0 @@ -#!/bin/sh -# $FreeBSD: ports/security/snort/files/snort.sh.in,v 1.4 2009/10/29 01:27:53 clsung Exp $ - -# PROVIDE: snort -# REQUIRE: DAEMON -# BEFORE: LOGIN -# KEYWORD: shutdown - -. /etc/rc.subr -. /var/etc/rc.snort - -name="snort" -rcvar=`set_rcvar` -start_cmd="snort_start" -stop_cmd="snort_stop" - -snort_bin="/usr/local/bin/snort" -barnyard_bin="/usr/local/bin/barnyard2" - -[ -z "$snort_enable" ] && snort_enable="YES" -[ -z "$snort_flags" ] && snort_flags="-u snort -g snort -D -q -l /var/log/snort" -[ -z "$barnyard_flags" ] && barnyard_flags="-u snort -g snort -d /var/log/snort" - -snort_start() -{ - echo -n 'Starting snort:' - for _s in ${snort_list} - do - echo -n " ${_s}" - - eval _conf=\"\$snort_${_s}_conf\" - eval _name=\"\$snort_${_s}_name\" - eval _id=\"\$snort_${_s}_id\" - eval _iface=\"\$snort_${_s}_interface\" - eval _enable=\"\$snort_${_s}_enable\" - eval _barnyard=\"\$snort_${_s}_barnyard\" - _confdir=${_conf%/*} - - _enable="${_enable:-YES}" - if ! checkyesno _enable; then - continue; - fi - - if [ -f /var/run/snort_${_iface}${_name}.pid ]; then - if pgrep -F /var/run/snort_${_iface}${_name}.pid snort; then - echo -n " [snort ${_s} already running]" - continue; - fi - fi - ${snort_bin} ${snort_flags} -G ${_id} -R ${_name} -c ${_conf} -i ${_iface} - - _barnyard="${_barnyard:-NO}" - if checkyesno _barnyard; then - ${barnyard_bin} ${snort_flags} -R ${_name} -c ${_confdir}/barnyard2.conf \ - -f snort.u2_${_name} -w ${_confdir}/barnyard2.waldo - fi - done - echo -} - -snort_stop() -{ - echo -n 'Stopping snort:' - _pidlist='' - for _s in ${snort_list} - do - echo -n " ${_s}" - - eval _conf=\"\$snort_${_s}_conf\" - eval _name=\"\$snort_${_s}_name\" - eval _iface=\"\$snort_${_s}_interface\" - - if [ -f /var/run/snort_${_iface}${_name}.pid ]; then - _pid=$(pgrep -F /var/run/snort_${_iface}${_name}.pid snort) - if [ -n "${_pid}" ]; then - kill ${_pid} - _pidlist="${_pidlist} ${_pid}" - fi - fi - if [ -f /var/run/barnyard_${_iface}${_name}.pid ]; then - _pid=$(pgrep -F /var/run/barnyard_${_iface}${_name}.pid barnyard2) - if [ -n "${_pid}" ]; then - kill ${_pid} - _pidlist="${_pidlist} ${_pid}" - fi - fi - done - echo - wait_for_pids ${_pidlist} -} - -cmd="$1" -if [ $# -gt 0 ]; then - shift -fi -if [ -n "$*" ]; then - snort_list="$*" -fi -run_rc_command "${cmd}" diff --git a/config/snort-dev/snort.sh b/config/snort-dev/snort.sh new file mode 100755 index 00000000..5b725cfe --- /dev/null +++ b/config/snort-dev/snort.sh @@ -0,0 +1,99 @@ +#!/bin/sh +# $FreeBSD: ports/security/snort/files/snort.sh.in,v 1.4 2009/10/29 01:27:53 clsung Exp $ + +# PROVIDE: snort +# REQUIRE: DAEMON +# BEFORE: LOGIN +# KEYWORD: shutdown + +. /etc/rc.subr +. /var/etc/rc.snort + +name="snort" +rcvar=`set_rcvar` +start_cmd="snort_start" +stop_cmd="snort_stop" + +snort_bin="/usr/local/bin/snort" +barnyard_bin="/usr/local/bin/barnyard2" + +[ -z "$snort_enable" ] && snort_enable="YES" +[ -z "$snort_flags" ] && snort_flags="-u snort -g snort -D -q -l /var/log/snort" +[ -z "$barnyard_flags" ] && barnyard_flags="-u snort -g snort -d /var/log/snort" + +snort_start() +{ + echo -n 'Starting snort:' + for _s in ${snort_list} + do + echo -n " ${_s}" + + eval _conf=\"\$snort_${_s}_conf\" + eval _name=\"\$snort_${_s}_name\" + eval _id=\"\$snort_${_s}_id\" + eval _iface=\"\$snort_${_s}_interface\" + eval _enable=\"\$snort_${_s}_enable\" + eval _barnyard=\"\$snort_${_s}_barnyard\" + _confdir=${_conf%/*} + + _enable="${_enable:-YES}" + if ! checkyesno _enable; then + continue; + fi + + if [ -f /var/run/snort_${_iface}${_name}.pid ]; then + if pgrep -F /var/run/snort_${_iface}${_name}.pid snort; then + echo -n " [snort ${_s} already running]" + continue; + fi + fi + ${snort_bin} ${snort_flags} -G ${_id} -R ${_name} -c ${_conf} -i ${_iface} + + _barnyard="${_barnyard:-NO}" + if checkyesno _barnyard; then + ${barnyard_bin} ${snort_flags} -R ${_name} -c ${_confdir}/barnyard2.conf \ + -f snort.u2_${_name} -w ${_confdir}/barnyard2.waldo + fi + done + echo +} + +snort_stop() +{ + echo -n 'Stopping snort:' + _pidlist='' + for _s in ${snort_list} + do + echo -n " ${_s}" + + eval _conf=\"\$snort_${_s}_conf\" + eval _name=\"\$snort_${_s}_name\" + eval _iface=\"\$snort_${_s}_interface\" + + if [ -f /var/run/snort_${_iface}${_name}.pid ]; then + _pid=$(pgrep -F /var/run/snort_${_iface}${_name}.pid snort) + if [ -n "${_pid}" ]; then + kill ${_pid} + _pidlist="${_pidlist} ${_pid}" + fi + fi + if [ -f /var/run/barnyard_${_iface}${_name}.pid ]; then + _pid=$(pgrep -F /var/run/barnyard_${_iface}${_name}.pid barnyard2) + if [ -n "${_pid}" ]; then + kill ${_pid} + _pidlist="${_pidlist} ${_pid}" + fi + fi + done + echo + wait_for_pids ${_pidlist} +} + +cmd="$1" +if [ $# -gt 0 ]; then + shift +fi +if [ -n "$*" ]; then + snort_list="$*" +fi +run_rc_command "${cmd}" diff --git a/config/snort-dev/snort.xml b/config/snort-dev/snort.xml index 327428e5..79a17ca9 100644 --- a/config/snort-dev/snort.xml +++ b/config/snort-dev/snort.xml @@ -181,7 +181,7 @@ /usr/local/etc/rc.d/ 755 - http://www.pfsense.com/packages/config/snort-dev/snort + http://www.pfsense.com/packages/config/snort-dev/snort.sh diff --git a/config/snort-dev/snort_check_for_rule_updates.php b/config/snort-dev/snort_check_for_rule_updates.php index 8ec51081..d95e24ad 100644 --- a/config/snort-dev/snort_check_for_rule_updates.php +++ b/config/snort-dev/snort_check_for_rule_updates.php @@ -752,7 +752,7 @@ exec("/bin/sync ;/bin/sync ;/bin/sync ;/bin/sync ;/bin/sync ;/bin/sync ;/bin/syn /* if snort is running hardrestart, if snort is not running do nothing */ if (file_exists("/tmp/snort_download_halt.pid")) { - exec("/bin/sh /usr/local/etc/rc.d/snort\* start"); + exec("/bin/sh /usr/local/etc/rc.d/snort.sh start"); echo "The Rules update finished...\n"; echo "Snort has restarted with your new set of rules...\n"; exec("/usr/bin/logger -p daemon.info -i -t SnortStartup 'SNORT RULE UPDATE FINNISHED...'"); diff --git a/config/snort-dev/snort_interfaces.php b/config/snort-dev/snort_interfaces.php index 5d98105e..8e3f7570 100644 --- a/config/snort-dev/snort_interfaces.php +++ b/config/snort-dev/snort_interfaces.php @@ -82,7 +82,7 @@ if (isset($_POST['del_x'])) { /* dont flood the syslog code */ exec("/bin/cp /var/log/system.log /var/log/system.log.bk"); - exec("/bin/sh /usr/local/etc/rc.d/snort stop $rulei"); + exec("/bin/sh /usr/local/etc/rc.d/snort.sh stop $rulei"); /* stop syslog flood code */ $if_real_wan_rulei = $a_nat[$rulei]['interface']; @@ -170,10 +170,10 @@ if ($_GET['act'] == "toggle" && $_GET['id'] != "") $snort_pid = exec("pgrep -F /var/run/snort_{$if_real2}{$name}.pid snort"); if ($snort_pid != "") { - exec("/bin/sh /usr/local/etc/rc.d/snort stop $name"); + exec("/bin/sh /usr/local/etc/rc.d/snort.sh stop $name"); }else{ sync_snort_package_all(); - exec("/bin/sh /usr/local/etc/rc.d/snort start $name"); + exec("/bin/sh /usr/local/etc/rc.d/snort.sh start $name"); } header("Location: snort_interfaces.php"); } diff --git a/config/snort-dev/snort_interfaces_edit.php b/config/snort-dev/snort_interfaces_edit.php index 2da18160..3a384df5 100644 --- a/config/snort-dev/snort_interfaces_edit.php +++ b/config/snort-dev/snort_interfaces_edit.php @@ -294,7 +294,7 @@ if ($_POST["Submit"]) { if ($_POST["Submit2"]) { sync_snort_package_all(); sleep(1); - exec("/bin/sh /usr/local/etc/rc.d/snort restart {$id}{$if_real}"); + exec("/bin/sh /usr/local/etc/rc.d/snort.sh restart {$id}{$if_real}"); header("Location: /snort/snort_interfaces_edit.php?id=$id"); exit; } -- cgit v1.2.3