Last active
November 2, 2024 10:28
-
-
Save amanjuman/fe6324137c08b356061595e9f76a34b9 to your computer and use it in GitHub Desktop.
One Click Crowdsec Linux Install
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
## | |
## curl -s https://gist.githubusercontent.com/amanjuman/fe6324137c08b356061595e9f76a34b9/raw/b05185579853c8c779408c4bd48df2ea9e33c5a3/linux_install.sh | sudo bash | |
## | |
#!/bin/bash | |
# Function to detect Linux distribution | |
detect_distro() { | |
if [ -f /etc/os-release ]; then | |
. /etc/os-release | |
OS_NAME=$ID | |
OS_VERSION=$VERSION_ID | |
else | |
echo "Unsupported Linux distribution." | |
exit 1 | |
fi | |
} | |
# Function to install CrowdSec based on the distribution | |
install_crowdsec() { | |
case $OS_NAME in | |
ubuntu|debian) | |
echo "Installing CrowdSec on $OS_NAME..." | |
sudo apt-get update | |
sudo apt-get install -y curl | |
curl -s https://packagecloud.io/install/repositories/crowdsec/crowdsec/script.deb.sh | sudo bash | |
sudo apt-get install -y crowdsec | |
;; | |
centos|rocky|almalinux|fedora|rhel) | |
echo "Installing CrowdSec on $OS_NAME..." | |
sudo dnf install -y curl | |
curl -s https://packagecloud.io/install/repositories/crowdsec/crowdsec/script.rpm.sh | sudo bash | |
sudo dnf install -y crowdsec | |
;; | |
*) | |
echo "Your distribution is not supported in this script." | |
exit 1 | |
;; | |
esac | |
} | |
# Function to install bouncer | |
install_bouncer() { | |
echo "Do you want to install a CrowdSec bouncer as well? (y/n)" | |
read -r install_bouncer < /dev/tty | |
if [[ "$install_bouncer" == "y" || "$install_bouncer" == "Y" ]]; then | |
case $OS_NAME in | |
ubuntu|debian) | |
sudo apt-get install -y crowdsec-firewall-bouncer-iptables | |
;; | |
centos|rocky|almalinux|fedora|rhel) | |
sudo dnf install -y crowdsec-firewall-bouncer-iptables | |
;; | |
*) | |
echo "Bouncer installation not supported for this distribution." | |
;; | |
esac | |
echo "Bouncer installed successfully." | |
else | |
echo "Skipping bouncer installation." | |
fi | |
} | |
# Main script execution | |
detect_distro | |
install_crowdsec | |
install_bouncer | |
echo "CrowdSec installation completed." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment