Browse Source

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>
Manuel Sabban 3 years ago
parent
commit
1d955f4258
6 changed files with 21 additions and 8 deletions
  1. 1 1
      config/config.yaml
  2. 13 0
      debian/patches/config_plugins
  3. 1 0
      debian/patches/series
  4. 4 4
      debian/rules
  5. 1 2
      rpm/SPECS/crowdsec.spec
  6. 1 1
      wizard.sh

+ 1 - 1
config/config.yaml

@@ -12,7 +12,7 @@ config_paths:
   hub_dir: /etc/crowdsec/hub/
   hub_dir: /etc/crowdsec/hub/
   index_path: /etc/crowdsec/hub/.index.json
   index_path: /etc/crowdsec/hub/.index.json
   notification_dir: /etc/crowdsec/notifications/
   notification_dir: /etc/crowdsec/notifications/
-  plugin_dir: /var/lib/crowdsec/plugins/
+  plugin_dir: /usr/local/lib/crowdsec/plugins/
 crowdsec_service:
 crowdsec_service:
   acquisition_path: /etc/crowdsec/acquis.yaml
   acquisition_path: /etc/crowdsec/acquis.yaml
   parser_routines: 1
   parser_routines: 1

+ 13 - 0
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

+ 1 - 0
debian/patches/series

@@ -1 +1,2 @@
+config_plugins
 fix-wizard.patch
 fix-wizard.patch

+ 4 - 4
debian/rules

@@ -30,12 +30,12 @@ override_dh_auto_install:
 	mkdir -p debian/crowdsec/usr/share/crowdsec/config
 	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/
 	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/slack/slack.yaml debian/crowdsec/etc/crowdsec/notifications/
 	cp plugins/notifications/http/http.yaml debian/crowdsec/etc/crowdsec/notifications/
 	cp plugins/notifications/http/http.yaml debian/crowdsec/etc/crowdsec/notifications/

+ 1 - 2
rpm/SPECS/crowdsec.spec

@@ -39,6 +39,7 @@ BuildRequires:  systemd
 
 
 %build
 %build
 BUILD_VERSION=%{local_version} make
 BUILD_VERSION=%{local_version} make
+sed -i "s#/usr/local/lib/crowdsec/plugins/#%{_libdir}/%{name}/plugins/#g" config/config.yaml
 
 
 %install
 %install
 rm -rf %{buildroot}
 rm -rf %{buildroot}
@@ -51,8 +52,6 @@ mkdir -p %{buildroot}%{_sharedstatedir}/%{name}/plugins
 mkdir -p %{buildroot}%{_sysconfdir}/crowdsec/notifications/
 mkdir -p %{buildroot}%{_sysconfdir}/crowdsec/notifications/
 mkdir -p %{buildroot}%{_libdir}/%{name}/plugins/
 mkdir -p %{buildroot}%{_libdir}/%{name}/plugins/
 
 
-
-
 install -m 755 -D cmd/crowdsec/crowdsec %{buildroot}%{_bindir}/%{name}
 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 cmd/crowdsec-cli/cscli %{buildroot}%{_bindir}/cscli
 install -m 755 -D wizard.sh %{buildroot}/usr/share/crowdsec/wizard.sh
 install -m 755 -D wizard.sh %{buildroot}/usr/share/crowdsec/wizard.sh

+ 1 - 1
wizard.sh

@@ -23,7 +23,7 @@ CROWDSEC_PATH="/etc/crowdsec"
 CROWDSEC_CONFIG_PATH="${CROWDSEC_PATH}"
 CROWDSEC_CONFIG_PATH="${CROWDSEC_PATH}"
 CROWDSEC_LOG_FILE="/var/log/crowdsec.log"
 CROWDSEC_LOG_FILE="/var/log/crowdsec.log"
 LAPI_LOG_FILE="/var/log/crowdsec_api.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"
 CROWDSEC_BIN="./cmd/crowdsec/crowdsec"
 CSCLI_BIN="./cmd/crowdsec-cli/cscli"
 CSCLI_BIN="./cmd/crowdsec-cli/cscli"