crowdsec/debian/patches/fix-wizard.patch

92 lines
3.3 KiB
Diff
Raw Normal View History

2021-08-18 11:57:06 +00:00
generate acquis.yaml directly in place
Index: crowdsec/wizard.sh
===================================================================
--- crowdsec.orig/wizard.sh
+++ crowdsec/wizard.sh
@@ -41,7 +41,6 @@
fi
ACQUIS_PATH="${CROWDSEC_CONFIG_PATH}"
-TMP_ACQUIS_FILE="tmp-acquis.yaml"
ACQUIS_TARGET="${ACQUIS_PATH}/acquis.yaml"
PID_DIR="${CROWDSEC_RUN_DIR}"
@@ -265,30 +264,30 @@
shift
local files=("${@}")
- echo "#Generated acquisition file - wizard.sh (service: ${service}) / files : ${files[@]}" >> ${TMP_ACQUIS_FILE}
+ echo "#Generated acquisition file - wizard.sh (service: ${service}) / files : ${files[@]}" >> ${ACQUIS_TARGET}
- echo "filenames:" >> ${TMP_ACQUIS_FILE}
+ echo "filenames:" >> ${ACQUIS_TARGET}
for fd in ${files[@]}; do
- echo " - ${fd}" >> ${TMP_ACQUIS_FILE}
+ echo " - ${fd}" >> ${ACQUIS_TARGET}
done
- echo "labels:" >> ${TMP_ACQUIS_FILE}
- echo " "${log_input_tags[${service}]} >> ${TMP_ACQUIS_FILE}
- echo "---" >> ${TMP_ACQUIS_FILE}
- log_dbg "tmp acquisition file generated to: ${TMP_ACQUIS_FILE}"
+ echo "labels:" >> ${ACQUIS_TARGET}
+ echo " "${log_input_tags[${service}]} >> ${ACQUIS_TARGET}
+ echo "---" >> ${ACQUIS_TARGET}
+ log_dbg "acquisition file generated to: ${ACQUIS_TARGET}"
}
genyamljournal() {
local service="${1}"
shift
- echo "#Generated acquisition file - wizard.sh (service: ${service}) / files : ${files[@]}" >> ${TMP_ACQUIS_FILE}
+ echo "#Generated acquisition file - wizard.sh (service: ${service}) / files : ${files[@]}" >> ${ACQUIS_TARGET}
- echo "journalctl_filter:" >> ${TMP_ACQUIS_FILE}
- echo " - _SYSTEMD_UNIT="${service}".service" >> ${TMP_ACQUIS_FILE}
- echo "labels:" >> ${TMP_ACQUIS_FILE}
- echo " "${log_input_tags[${service}]} >> ${TMP_ACQUIS_FILE}
- echo "---" >> ${TMP_ACQUIS_FILE}
- log_dbg "tmp acquisition file generated to: ${TMP_ACQUIS_FILE}"
+ echo "journalctl_filter:" >> ${ACQUIS_TARGET}
+ echo " - _SYSTEMD_UNIT="${service}".service" >> ${ACQUIS_TARGET}
+ echo "labels:" >> ${ACQUIS_TARGET}
+ echo " "${log_input_tags[${service}]} >> ${ACQUIS_TARGET}
+ echo "---" >> ${ACQUIS_TARGET}
+ log_dbg "acquisition file generated to: ${ACQUIS_TARGET}"
}
genacquisition() {
@@ -569,7 +568,6 @@
${CSCLI_BIN_INSTALLED} hub update
install_collection
genacquisition
- mv "${TMP_ACQUIS_FILE}" "${ACQUIS_TARGET}"
return
fi
@@ -628,7 +626,6 @@
# Generate acquisition file and move it to the right folder
genacquisition
- mv "${TMP_ACQUIS_FILE}" "${ACQUIS_TARGET}"
log_info "acquisition file path: ${ACQUIS_TARGET}"
# Install collections according to detected services
log_dbg "Installing needed collections ..."
@@ -656,7 +653,6 @@
if [[ "$1" == "detect" ]];
then
- rm -f "${TMP_ACQUIS_FILE}"
detect_services
if [[ ${DETECTED_SERVICES} == "" ]] ; then
log_err "No detected or selected services, stopping."
@@ -664,8 +660,7 @@
fi;
log_info "Found ${#DETECTED_SERVICES[@]} supported services running:"
genacquisition
- cat "${TMP_ACQUIS_FILE}"
- rm "${TMP_ACQUIS_FILE}"
+ cat "${ACQUIS_TARGET}"
return
fi