Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. echo "Installation du client Zabbix pour Hifumin (c'est gentil ça !)"
  3. if [ "$(lsb_release -is)" != "Debian" ]; then
  4. echo 'Ce script fonctionne uniquement avec Debian 9 et 10' >&2
  5. exit 1
  6. fi
  7. if [ "$(lsb_release -cs)" == "buster" ]; then
  8. echo "deb http://repo.zabbix.com/zabbix/4.2/debian buster main
  9. deb-src http://repo.zabbix.com/zabbix/4.2/debian buster main" > /etc/apt/sources.list.d/zabbix.list
  10. elif [ "$(lsb_release -cs)" == "stretch" ]; then
  11. echo "deb http://repo.zabbix.com/zabbix/4.2/debian stretch main
  12. deb-src http://repo.zabbix.com/zabbix/4.2/debian stretch main" > /etc/apt/sources.list.d/zabbix.list
  13. fi
  14. wget https://repo.zabbix.com/zabbix-official-repo.key
  15. apt-key add zabbix-official-repo.key
  16. rm zabbix-official-repo.key
  17. apt update
  18. apt install zabbix-agent
  19.  
  20. curl -Ss https://leonekmi.fr/zabbix.conf > /etc/zabbix/zabbix_agentd.conf
  21. if [ -x "$(command -v iptables-nft)" ]; then
  22. echo 'Création de règles iptables (nft)' >&2
  23. iptables-nft add rule ip filter INPUT ip saddr 138.201.145.226 tcp dport 10050 counter accept
  24. iptables-nft add rule ip filter INPUT ip saddr 138.201.145.226 udp dport 10050 counter accept
  25. if [ -x "$(command -v ip6tables-nft)" ]; then
  26. ip6tables-nft add rule ip6 filter INPUT ip6 saddr 2a01:4f8:171:661:3::2 tcp dport 10050 counter accept
  27. ip6tables-nft add rule ip6 filter INPUT ip6 saddr 2a01:4f8:171:661:3::2 udp dport 10050 counter accept
  28. fi
  29. elif [ -x "$(command -v iptables)" ]; then
  30. echo 'Création de règles iptables (legacy)' >&2
  31. iptables -A INPUT -s 138.201.145.226/32 -p tcp -m tcp --dport 10050 -j ACCEPT
  32. iptables -A INPUT -s 138.201.145.226/32 -p udp -m udp --dport 10050 -j ACCEPT
  33. if [ -x "$(command -v ip6tables)" ]; then
  34. ip6tables -A INPUT -s 2a01:4f8:171:661:3::2/128 -p tcp -m tcp --dport 10050 -j ACCEPT
  35. ip6tables -A INPUT -s 2a01:4f8:171:661:3::2/128 -p udp -m udp --dport 10050 -j ACCEPT
  36. fi
  37. fi
  38. systemctl start zabbix-agent
  39. systemctl enable zabbix-agent
  40. systemctl restart zabbix-agent
  41. systemctl status zabbix-agent
  42. 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