Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- echo "Installation du client Zabbix pour Hifumin (c'est gentil ça !)"
- if [ "$(lsb_release -is)" != "Debian" ]; then
- echo 'Ce script fonctionne uniquement avec Debian 9 et 10' >&2
- exit 1
- fi
- if [ "$(lsb_release -cs)" == "buster" ]; then
- echo "deb http://repo.zabbix.com/zabbix/4.2/debian buster main
- deb-src http://repo.zabbix.com/zabbix/4.2/debian buster main" > /etc/apt/sources.list.d/zabbix.list
- elif [ "$(lsb_release -cs)" == "stretch" ]; then
- echo "deb http://repo.zabbix.com/zabbix/4.2/debian stretch main
- deb-src http://repo.zabbix.com/zabbix/4.2/debian stretch main" > /etc/apt/sources.list.d/zabbix.list
- fi
- wget https://repo.zabbix.com/zabbix-official-repo.key
- apt-key add zabbix-official-repo.key
- rm zabbix-official-repo.key
- apt update
- apt install zabbix-agent
- curl -Ss https://leonekmi.fr/zabbix.conf > /etc/zabbix/zabbix_agentd.conf
- if [ -x "$(command -v iptables-nft)" ]; then
- echo 'Création de règles iptables (nft)' >&2
- iptables-nft add rule ip filter INPUT ip saddr 138.201.145.226 tcp dport 10050 counter accept
- iptables-nft add rule ip filter INPUT ip saddr 138.201.145.226 udp dport 10050 counter accept
- if [ -x "$(command -v ip6tables-nft)" ]; then
- ip6tables-nft add rule ip6 filter INPUT ip6 saddr 2a01:4f8:171:661:3::2 tcp dport 10050 counter accept
- ip6tables-nft add rule ip6 filter INPUT ip6 saddr 2a01:4f8:171:661:3::2 udp dport 10050 counter accept
- fi
- elif [ -x "$(command -v iptables)" ]; then
- echo 'Création de règles iptables (legacy)' >&2
- iptables -A INPUT -s 138.201.145.226/32 -p tcp -m tcp --dport 10050 -j ACCEPT
- iptables -A INPUT -s 138.201.145.226/32 -p udp -m udp --dport 10050 -j ACCEPT
- if [ -x "$(command -v ip6tables)" ]; then
- ip6tables -A INPUT -s 2a01:4f8:171:661:3::2/128 -p tcp -m tcp --dport 10050 -j ACCEPT
- ip6tables -A INPUT -s 2a01:4f8:171:661:3::2/128 -p udp -m udp --dport 10050 -j ACCEPT
- fi
- fi
- systemctl start zabbix-agent
- systemctl enable zabbix-agent
- systemctl restart zabbix-agent
- systemctl status zabbix-agent
- echo "C'est installé ! Des règles iptables ont été crées automatiquement si possible, pensez à sauvegarder la configuration de votre firewall."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement