b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | #!/bin/sh /etc/rc.common |
| 2 | |
| 3 | START=99 |
| 4 | STOP=10 |
| 5 | |
| 6 | USE_PROCD=1 |
| 7 | PROG=/usr/bin/snort |
| 8 | |
| 9 | validate_snort_section() { |
| 10 | uci_validate_section snort snort "${1}" \ |
| 11 | 'config_dir:string' \ |
| 12 | 'alert_module:string' \ |
| 13 | 'interface:string' |
| 14 | } |
| 15 | |
| 16 | start_service() { |
| 17 | local config_file interface |
| 18 | |
| 19 | validate_snort_section snort || { |
| 20 | echo "validation failed" |
| 21 | return 1 |
| 22 | } |
| 23 | |
| 24 | procd_open_instance |
| 25 | procd_set_param command $PROG -q --daq-dir /usr/lib/daq/ -i "$interface" -c "$config_dir/snort.lua" -A "$alert_module" |
| 26 | procd_set_param env SNORT_LUA_PATH="$config_dir" |
| 27 | procd_set_param file $CONFIGFILE |
| 28 | procd_set_param respawn |
| 29 | procd_close_instance |
| 30 | } |
| 31 | |
| 32 | stop_service() |
| 33 | { |
| 34 | service_stop ${PROG} |
| 35 | } |
| 36 | |
| 37 | service_triggers() |
| 38 | { |
| 39 | procd_add_reload_trigger "snort" |
| 40 | procd_add_validation validate_snort_section |
| 41 | } |