diff options
| author | Mingli Yu <mingli.yu@windriver.com> | 2023-07-12 17:43:34 +0800 |
|---|---|---|
| committer | Khem Raj <raj.khem@gmail.com> | 2023-07-12 16:19:40 -0700 |
| commit | 314ed1c230ce134ba4b7bc2705fe7ce502238623 (patch) | |
| tree | a9cd46b1f0244bf346173a96f4bf6fe1a1ee90fe | |
| parent | 5d03a8a66022fd24a72d64777526c602238df35c (diff) | |
| download | meta-openembedded-314ed1c230ce134ba4b7bc2705fe7ce502238623.tar.gz | |
snort: Add systemd unit file
Add systemd unit file snort.service.
Reference: https://salsa.debian.org/lts-team/packages/snort/-/blob/debian/buster/debian/snort.service.example
Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
3 files changed, 31 insertions, 2 deletions
diff --git a/meta-networking/recipes-connectivity/snort/snort/snort.default b/meta-networking/recipes-connectivity/snort/snort/snort.default new file mode 100644 index 0000000000..f1f67c55c0 --- /dev/null +++ b/meta-networking/recipes-connectivity/snort/snort/snort.default | |||
| @@ -0,0 +1 @@ | |||
| INTERFACES="eth0" | |||
diff --git a/meta-networking/recipes-connectivity/snort/snort/snort.service b/meta-networking/recipes-connectivity/snort/snort/snort.service new file mode 100644 index 0000000000..487328c1b0 --- /dev/null +++ b/meta-networking/recipes-connectivity/snort/snort/snort.service | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | [Unit] | ||
| 2 | Description=Snort NIDS Daemon | ||
| 3 | After=syslog.target network.target | ||
| 4 | |||
| 5 | [Service] | ||
| 6 | Type=simple | ||
| 7 | EnvironmentFile=/etc/default/snort | ||
| 8 | ExecStartPre=/bin/mkdir -p /var/log/snort | ||
| 9 | ExecStart=/usr/bin/snort -q -c /etc/snort/snort.conf -l /var/log/snort -i $INTERFACES | ||
| 10 | |||
| 11 | [Install] | ||
| 12 | WantedBy=multi-user.target | ||
diff --git a/meta-networking/recipes-connectivity/snort/snort_2.9.20.bb b/meta-networking/recipes-connectivity/snort/snort_2.9.20.bb index c15c20443d..8b9092b418 100644 --- a/meta-networking/recipes-connectivity/snort/snort_2.9.20.bb +++ b/meta-networking/recipes-connectivity/snort/snort_2.9.20.bb | |||
| @@ -8,6 +8,8 @@ DEPENDS = "xz libpcap libpcre daq libdnet util-linux daq-native libtirpc bison-n | |||
| 8 | 8 | ||
| 9 | SRC_URI = "https://www.snort.org/downloads/archive/snort/${BP}.tar.gz \ | 9 | SRC_URI = "https://www.snort.org/downloads/archive/snort/${BP}.tar.gz \ |
| 10 | file://snort.init \ | 10 | file://snort.init \ |
| 11 | file://snort.service \ | ||
| 12 | file://snort.default \ | ||
| 11 | file://volatiles.99_snort \ | 13 | file://volatiles.99_snort \ |
| 12 | file://0001-libpcap-search-sysroot-for-headers.patch \ | 14 | file://0001-libpcap-search-sysroot-for-headers.patch \ |
| 13 | file://fix-host-contamination-when-enable-static-daq.patch \ | 15 | file://fix-host-contamination-when-enable-static-daq.patch \ |
| @@ -19,11 +21,15 @@ SRC_URI[sha256sum] = "29400e13f53b1831e0b8b10ec1224a1cbaa6dc1533a5322a20dd80bb84 | |||
| 19 | UPSTREAM_CHECK_URI = "https://www.snort.org/downloads" | 21 | UPSTREAM_CHECK_URI = "https://www.snort.org/downloads" |
| 20 | UPSTREAM_CHECK_REGEX = "snort-(?P<pver>\d+(\.\d+)+)\.tar" | 22 | UPSTREAM_CHECK_REGEX = "snort-(?P<pver>\d+(\.\d+)+)\.tar" |
| 21 | 23 | ||
| 22 | inherit autotools gettext update-rc.d pkgconfig | 24 | inherit autotools gettext update-rc.d pkgconfig systemd |
| 23 | 25 | ||
| 24 | INITSCRIPT_NAME = "snort" | 26 | INITSCRIPT_NAME = "snort" |
| 25 | INITSCRIPT_PARAMS = "defaults" | 27 | INITSCRIPT_PARAMS = "defaults" |
| 26 | 28 | ||
| 29 | SYSTEMD_PACKAGES = "${PN}" | ||
| 30 | SYSTEMD_SERVICE:${PN} = "snort.service" | ||
| 31 | SYSTEMD_AUTO_ENABLE = "disable" | ||
| 32 | |||
| 27 | EXTRA_OECONF = " \ | 33 | EXTRA_OECONF = " \ |
| 28 | --enable-gre \ | 34 | --enable-gre \ |
| 29 | --enable-linux-smp-stats \ | 35 | --enable-linux-smp-stats \ |
| @@ -69,8 +75,17 @@ do_install:append() { | |||
| 69 | ${D}${sysconfdir}/snort/snort.conf | 75 | ${D}${sysconfdir}/snort/snort.conf |
| 70 | 76 | ||
| 71 | cp ${S}/preproc_rules/*.rules ${D}${sysconfdir}/snort/preproc_rules/ | 77 | cp ${S}/preproc_rules/*.rules ${D}${sysconfdir}/snort/preproc_rules/ |
| 72 | install -m 755 ${WORKDIR}/snort.init ${D}${sysconfdir}/init.d/snort | 78 | if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then |
| 79 | install -m 755 ${WORKDIR}/snort.init ${D}${sysconfdir}/init.d/snort | ||
| 80 | fi | ||
| 73 | 81 | ||
| 82 | if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then | ||
| 83 | install -d ${D}/${systemd_system_unitdir} | ||
| 84 | install -m 644 ${WORKDIR}/snort.service ${D}/${systemd_system_unitdir} | ||
| 85 | # Install default environment file | ||
| 86 | install -d ${D}/${sysconfdir}/default | ||
| 87 | install -m 0644 ${WORKDIR}/snort.default ${D}${sysconfdir}/default/snort | ||
| 88 | fi | ||
| 74 | install -d ${D}${sysconfdir}/default/volatiles | 89 | install -d ${D}${sysconfdir}/default/volatiles |
| 75 | install -m 0644 ${WORKDIR}/volatiles.99_snort ${D}${sysconfdir}/default/volatiles/99_snort | 90 | install -m 0644 ${WORKDIR}/volatiles.99_snort ${D}${sysconfdir}/default/volatiles/99_snort |
| 76 | 91 | ||
| @@ -87,6 +102,7 @@ FILES:${PN} += " \ | |||
| 87 | ${libdir}/snort_dynamicengine/*.so.* \ | 102 | ${libdir}/snort_dynamicengine/*.so.* \ |
| 88 | ${libdir}/snort_dynamicpreprocessor/*.so.* \ | 103 | ${libdir}/snort_dynamicpreprocessor/*.so.* \ |
| 89 | ${libdir}/snort_dynamicrules/*.so.* \ | 104 | ${libdir}/snort_dynamicrules/*.so.* \ |
| 105 | ${systemd_system_unitdir}/snort.service \ | ||
| 90 | " | 106 | " |
| 91 | FILES:${PN}-dbg += " \ | 107 | FILES:${PN}-dbg += " \ |
| 92 | ${libdir}/snort_dynamicengine/.debug \ | 108 | ${libdir}/snort_dynamicengine/.debug \ |
