From 1d955f4258167366fc18f0c73a3e8c48d2204c87 Mon Sep 17 00:00:00 2001 From: Manuel Sabban Date: Tue, 7 Sep 2021 17:18:55 +0200 Subject: [PATCH] fix plugins directories (#942) * use usr over var for plugins * add patch for debian directory * patch rpm conf as well * update directory structure * modify config at build time * use macros Co-authored-by: sabban <15465465+sabban@users.noreply.github.com> --- config/config.yaml | 2 +- debian/patches/config_plugins | 13 +++++++++++++ debian/patches/series | 1 + debian/rules | 8 ++++---- rpm/SPECS/crowdsec.spec | 3 +-- wizard.sh | 2 +- 6 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 debian/patches/config_plugins diff --git a/config/config.yaml b/config/config.yaml index 9c793ded2..877b97142 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -12,7 +12,7 @@ config_paths: hub_dir: /etc/crowdsec/hub/ index_path: /etc/crowdsec/hub/.index.json notification_dir: /etc/crowdsec/notifications/ - plugin_dir: /var/lib/crowdsec/plugins/ + plugin_dir: /usr/local/lib/crowdsec/plugins/ crowdsec_service: acquisition_path: /etc/crowdsec/acquis.yaml parser_routines: 1 diff --git a/debian/patches/config_plugins b/debian/patches/config_plugins new file mode 100644 index 000000000..5773edde3 --- /dev/null +++ b/debian/patches/config_plugins @@ -0,0 +1,13 @@ +Index: crowdsec/config/config.yaml +=================================================================== +--- crowdsec.orig/config/config.yaml ++++ crowdsec/config/config.yaml +@@ -12,7 +12,7 @@ config_paths: + hub_dir: /etc/crowdsec/hub/ + index_path: /etc/crowdsec/hub/.index.json + notification_dir: /etc/crowdsec/notifications/ +- plugin_dir: /usr/local/lib/crowdsec/plugins/ ++ plugin_dir: /usr/lib/crowdsec/plugins/ + crowdsec_service: + acquisition_path: /etc/crowdsec/acquis.yaml + parser_routines: 1 diff --git a/debian/patches/series b/debian/patches/series index ca1451cb0..db49547ed 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1 +1,2 @@ +config_plugins fix-wizard.patch diff --git a/debian/rules b/debian/rules index 090565799..9201ba617 100755 --- a/debian/rules +++ b/debian/rules @@ -30,12 +30,12 @@ override_dh_auto_install: mkdir -p debian/crowdsec/usr/share/crowdsec/config - mkdir -p debian/crowdsec/var/lib/crowdsec/plugins/ + mkdir -p debian/crowdsec/usr/lib/crowdsec/plugins/ mkdir -p debian/crowdsec/etc/crowdsec/notifications/ - install -m 551 plugins/notifications/slack/notification-slack debian/crowdsec/var/lib/crowdsec/plugins/ - install -m 551 plugins/notifications/http/notification-http debian/crowdsec/var/lib/crowdsec/plugins/ - install -m 551 plugins/notifications/splunk/notification-splunk debian/crowdsec/var/lib/crowdsec/plugins/ + install -m 551 plugins/notifications/slack/notification-slack debian/crowdsec/usr/lib/crowdsec/plugins/ + install -m 551 plugins/notifications/http/notification-http debian/crowdsec/usr/lib/crowdsec/plugins/ + install -m 551 plugins/notifications/splunk/notification-splunk debian/crowdsec/usr/lib/crowdsec/plugins/ cp plugins/notifications/slack/slack.yaml debian/crowdsec/etc/crowdsec/notifications/ cp plugins/notifications/http/http.yaml debian/crowdsec/etc/crowdsec/notifications/ diff --git a/rpm/SPECS/crowdsec.spec b/rpm/SPECS/crowdsec.spec index 2bebbaf76..738834237 100644 --- a/rpm/SPECS/crowdsec.spec +++ b/rpm/SPECS/crowdsec.spec @@ -39,6 +39,7 @@ BuildRequires: systemd %build BUILD_VERSION=%{local_version} make +sed -i "s#/usr/local/lib/crowdsec/plugins/#%{_libdir}/%{name}/plugins/#g" config/config.yaml %install rm -rf %{buildroot} @@ -51,8 +52,6 @@ mkdir -p %{buildroot}%{_sharedstatedir}/%{name}/plugins mkdir -p %{buildroot}%{_sysconfdir}/crowdsec/notifications/ mkdir -p %{buildroot}%{_libdir}/%{name}/plugins/ - - install -m 755 -D cmd/crowdsec/crowdsec %{buildroot}%{_bindir}/%{name} install -m 755 -D cmd/crowdsec-cli/cscli %{buildroot}%{_bindir}/cscli install -m 755 -D wizard.sh %{buildroot}/usr/share/crowdsec/wizard.sh diff --git a/wizard.sh b/wizard.sh index 26c39fe3c..cb15e0792 100755 --- a/wizard.sh +++ b/wizard.sh @@ -23,7 +23,7 @@ CROWDSEC_PATH="/etc/crowdsec" CROWDSEC_CONFIG_PATH="${CROWDSEC_PATH}" CROWDSEC_LOG_FILE="/var/log/crowdsec.log" LAPI_LOG_FILE="/var/log/crowdsec_api.log" -CROWDSEC_PLUGIN_DIR="/var/lib/crowdsec/plugins/" +CROWDSEC_PLUGIN_DIR="${CROWDSEC_USR_DIR}/plugins" CROWDSEC_BIN="./cmd/crowdsec/crowdsec" CSCLI_BIN="./cmd/crowdsec-cli/cscli"