mirror of
https://github.com/unifi-utilities/unifios-utilities.git
synced 2024-08-30 18:32:21 +00:00
Suricata Boot Script Maintainability Update (#52)
Moved from an inline escaping style to shell redirection with parameter expansion turned off. Also now supports any directory with *.rules files in /mnt/data/suricata-rules/ to support easier handling of expansion from bundled tar/zip files.
This commit is contained in:
parent
715a4924cc
commit
d08b5224c4
@ -2,21 +2,30 @@
|
|||||||
|
|
||||||
APP_PID="/run/suricata.pid"
|
APP_PID="/run/suricata.pid"
|
||||||
|
|
||||||
echo "#!/bin/sh
|
cat <<"EOF" > /tmp/suricata.sh
|
||||||
CUSTOM_RULES=\"/mnt/data/suricata-rules\"
|
#!/bin/sh
|
||||||
|
CUSTOM_RULES="/mnt/data/suricata-rules"
|
||||||
|
|
||||||
for file in \"\$CUSTOM_RULES\"/*.rules
|
for file in $(find ${CUSTOM_RULES} -name '*.rules' -print)
|
||||||
do
|
do
|
||||||
if [ -f \"\$file\" ]; then
|
if [ -f "${file}" ]; then
|
||||||
cp \"\$file\" \"/run/ips/rules/\$(basename \"\$file\")\"
|
bname=$(basename ${file})
|
||||||
echo \" - \$(basename \"\$file\")\" >> /run/ips/config/rules.yaml
|
cp "${file}" "/run/ips/rules/${bname}"
|
||||||
|
# Check if the existing filename is already in the rules.yaml based upon a previous update
|
||||||
|
grep -wq "${bname}" /run/ips/config/rules.yaml
|
||||||
|
# Don't add twice if it is in the file already
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo " - ${bname}" >> /run/ips/config/rules.yaml
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
CONTAINER=suricata
|
CONTAINER=suricata
|
||||||
if podman container exists \${CONTAINER}; then
|
if podman container exists ${CONTAINER}; then
|
||||||
podman rm -f \${CONTAINER}
|
podman rm -f ${CONTAINER}
|
||||||
fi
|
fi
|
||||||
podman run --network=host --privileged --name \${CONTAINER} --rm -it -v /run:/var/run/ -v /run:/run -v /usr/share/ubios-udapi-server/ips/:/usr/share/ubios-udapi-server/ips/ jasonish/suricata:5.0.3-arm64v8 /usr/bin/suricata \"\$@\"" > /tmp/suricata.sh
|
podman run --network=host --privileged --name ${CONTAINER} --rm -it -v /run:/var/run/ -v /run:/run -v /usr/share/ubios-udapi-server/ips/:/usr/share/ubios-udapi-server/ips/ jasonish/suricata:5.0.3-arm64v8 /usr/bin/suricata "$@"
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
chmod +x /tmp/suricata.sh
|
chmod +x /tmp/suricata.sh
|
||||||
cp /usr/bin/suricata /tmp/suricata.backup # In case you want to move back without rebooting
|
cp /usr/bin/suricata /tmp/suricata.backup # In case you want to move back without rebooting
|
||||||
@ -25,4 +34,4 @@ ln -f -s /tmp/suricata.sh /usr/bin/suricata
|
|||||||
if [ ! -z "$APP_PID" ]; then
|
if [ ! -z "$APP_PID" ]; then
|
||||||
killall -9 suricata
|
killall -9 suricata
|
||||||
rm -f APP_PID
|
rm -f APP_PID
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user