Created
July 6, 2023 08:41
-
-
Save LaurenceJJones/6960107296145e8e365009973b9d7f6d to your computer and use it in GitHub Desktop.
crowdsec debian symlinks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
TMP_DIR=$(mktemp -d) | |
dump_tree() { | |
cscli "$1" list --output raw | cut -d, -f1 | grep -v ^name$ > "$TMP_DIR/$1.txt" | |
} | |
check_root() { | |
if [[ $EUID -ne 0 ]]; then | |
echo "This script must be run as root" | |
exit 1 | |
fi | |
} | |
load_tree() { | |
rm -rf "/etc/crowdsec/$1" && mkdir -p "/etc/crowdsec/$1" | |
#shellcheck disable=SC2046 | |
cscli "$1" install --force --ignore $(cat "$TMP_DIR/$1.txt") | |
} | |
check_root | |
for i in parsers scenarios postoverflows collections; do | |
dump_tree "$i" | |
load_tree "$i" | |
done | |
rm -rf "$TMP_DIR" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment