Skip to content

Commit

Permalink
style: fixed indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaile committed Jan 13, 2025
1 parent e6795b2 commit 87abb13
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions packages/snort3/files/snort.init
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,33 @@ update_bypass_set() {
else
echo -n "elements = {" > $set_file
for ip in $ips; do
echo -n "$(echo "$ip" | cut -d, -f1)," >> $set_file
echo -n "$(echo "$ip" | cut -d, -f1)," >> $set_file
done
echo " }" >> $set_file
fi
fi
}

download_rules () {
oinkcode="$(uci -q get snort.snort.oinkcode)"
if [ -n "$oinkcode" ]; then
rm -f /var/ns-snort/*community-rules.tar.gz
rules="$(find /var/ns-snort -type f -name "snortrules-*.tar.gz")"
[ -n "$rules" ] && return
else
rm -f /var/ns-snort/snortrules-*.tar.gz
rules="$(find /var/ns-snort/ -type f -name "*community-rules.tar.gz")"
[ -n "$rules" ] && return
fi
# this is done every time the service is started
attempt=0
until /usr/bin/ns-snort-rules --download; do
attempt=$((attempt + 1))
if [ "$attempt" -ge 6 ]; then
echo "Error: failed to download snort rules after 6 attempts (1 minute)."
break
fi
sleep 10
done
oinkcode="$(uci -q get snort.snort.oinkcode)"
if [ -n "$oinkcode" ]; then
rm -f /var/ns-snort/*community-rules.tar.gz
rules="$(find /var/ns-snort -type f -name "snortrules-*.tar.gz")"
[ -n "$rules" ] && return
else
rm -f /var/ns-snort/snortrules-*.tar.gz
rules="$(find /var/ns-snort/ -type f -name "*community-rules.tar.gz")"
[ -n "$rules" ] && return
fi
# this is done every time the service is started
attempt=0
until /usr/bin/ns-snort-rules --download; do
attempt=$((attempt + 1))
if [ "$attempt" -ge 6 ]; then
echo "Error: failed to download snort rules after 6 attempts (1 minute)."
break
fi
sleep 10
done
}

setup_tweaks() {
Expand All @@ -76,7 +76,7 @@ start_service() {
# output.logdir, in the snort lua config, determines the PID file location.
# Add '--create-pidfile' to the 'command', below.

local enabled
local enabled
local manual
local config_dir
local interface
Expand All @@ -94,17 +94,17 @@ start_service() {
setup_tweaks
fi

validate_snort_section snort || {
echo "Validation failed, try 'snort-mgr check'."
return 1
}
validate_snort_section snort || {
echo "Validation failed, try 'snort-mgr check'."
return 1
}

[ "$enabled" = 0 ] && return

procd_open_instance
if [ "$manual" = 0 ]; then
local config_file=$($MGR setup)
maxlen=$(uci -q get snort.nfq.queue_maxlen)
maxlen=$(uci -q get snort.nfq.queue_maxlen)
if [ -z "${maxlen}" ]; then
maxlen=1024
fi
Expand Down Expand Up @@ -134,6 +134,6 @@ service_triggers()

reload_service()
{
stop
start
stop
start
}

0 comments on commit 87abb13

Please sign in to comment.