Browse Source

added zabbix agent install, some fix

Bachir Soussi Chiadmi 6 years ago
parent
commit
30f38a09a1
5 changed files with 51 additions and 14 deletions
  1. 3 3
      bin/fail2ban.sh
  2. 4 4
      bin/firewall.sh
  3. 4 4
      bin/knockd.sh
  4. 3 3
      bin/misc.sh
  5. 37 0
      bin/zabbix.sh

+ 3 - 3
bin/fail2ban.sh

@@ -2,14 +2,14 @@
 
 # TODO check if root
 
-echo '\033[35m
+echo -e '\033[35m
     ______      _ _____   __
    / ____/___ _(_) /__ \ / /_  ____ _____
   / /_  / __ `/ / /__/ // __ \/ __ `/ __ \
  / __/ / /_/ / / // __// /_/ / /_/ / / / /
 /_/    \__,_/_/_//____/_.___/\__,_/_/ /_/
 \033[0m'
-echo "\033[35;1mInstalling fall2ban \033[0m"
+echo -e "\033[35;1mInstalling fall2ban \033[0m"
 
 if [ "$EUID" -ne 0 ]; then
   echo "Please run as root"
@@ -22,4 +22,4 @@ cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
 # ToDo ask for email and configure jail.local with it
 systemctl enable fail2ban
 systemctl restart fail2ban
-echo "\033[92;1mfail2ban installed and configured\033[Om"
+echo -e "\033[92;1mfail2ban installed and configured\033[Om"

+ 4 - 4
bin/firewall.sh

@@ -2,14 +2,14 @@
 
 # TODO check if root
 
-echo '\033[35m
+echo -e '\033[35m
     ______________  _______       _____    __    __
    / ____/  _/ __ \/ ____/ |     / /   |  / /   / /
   / /_   / // /_/ / __/  | | /| / / /| | / /   / /
  / __/ _/ // _, _/ /___  | |/ |/ / ___ |/ /___/ /___
 /_/   /___/_/ |_/_____/  |__/|__/_/  |_/_____/_____/
 \033[0m'
-echo "\033[35;1mInstalling ufw and setup firewall (allowing only ssh and http) \033[0m"
+echo -e "\033[35;1mInstalling ufw and setup firewall (allowing only ssh and http) \033[0m"
 
 if [ "$EUID" -ne 0 ]; then
   echo "Please run as root"
@@ -22,8 +22,8 @@ apt-get --yes --force-yes install ufw
 ufw allow http
 ufw allow https
 
-# TODO ask for allowing ssh for some ip 
+# TODO ask for allowing ssh for some ip
 
 ufw enable
 ufw status verbose
-echo "\033[92;1mufw installed and firwall configured\033[Om"
+echo -e "\033[92;1mufw installed and firwall configured\033[Om"

+ 4 - 4
bin/knockd.sh

@@ -2,14 +2,14 @@
 
 # TODO check if root
 
-echo '\033[35m
+echo -e '\033[35m
     __                    __       __
    / /______  ____  _____/ /______/ /
   / //_/ __ \/ __ \/ ___/ //_/ __  /
  / ,< / / / / /_/ / /__/ ,< / /_/ /
 /_/|_/_/ /_/\____/\___/_/|_|\__,_/
 \033[0m'
-echo "\033[35;1mInstalling knockd to control ssh port opening\033[0m"
+echo -e "\033[35;1mInstalling knockd to control ssh port opening\033[0m"
 
 if [ "$EUID" -ne 0 ]; then
   echo "Please run as root"
@@ -42,7 +42,7 @@ systemctl start knockd
 # patch https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=868015
 # systemctl enable knockd
 
-echo "\033[92;1mknockd installed and configured\033[Om"
-echo "\033[92;1mplease note this sequence for future ssh knocking\033[Om"
+echo -e "\033[92;1mknockd installed and configured\033[Om"
+echo -e "\033[92;1mplease note this sequence for future ssh knocking\033[Om"
 echo "$sq1"
 sleep 3

+ 3 - 3
bin/misc.sh

@@ -1,8 +1,6 @@
 #!/bin/sh
 
-# TODO check if root
-
-echo '\033[35m
+echo -e '\033[35m
     __  ____
    /  |/  (_)_________
   / /|_/ / / ___/ ___/
@@ -23,3 +21,5 @@ locale-gen
 apt-get --yes --force-yes install ntp
 dpkg-reconfigure tzdata
 apt-get --yes --force-yes install needrestart
+
+echo -e "\033[92;1mMisc done \033[Om"

+ 37 - 0
bin/zabbix.sh

@@ -0,0 +1,37 @@
+#!/bin/sh
+
+
+echo -e '\033[35m
+ _____         __    __    _
+/__  /  ____ _/ /_  / /_  (_)  __
+  / /  / __ `/ __ \/ __ \/ / |/_/
+ / /__/ /_/ / /_/ / /_/ / />  <
+/____/\__,_/_.___/_.___/_/_/|_|
+\033[0m'
+
+if [ "$EUID" -ne 0 ]; then
+  echo "Please run as root"
+  exit
+fi
+
+
+wget http://repo.zabbix.com/zabbix/3.4/debian/pool/main/z/zabbix-release/zabbix-release_3.4-1+stretch_all.deb
+dpkg -i zabbix-release_3.0-2+stretch_all.deb
+
+apt-get update -y
+
+apt-get install zabbix-agent -y
+
+# configure
+echo -n "Please provide the zabbix-server's ip : "
+read _ip
+echo -n "Please provide the hostname of this agent : "
+read _host_name
+
+sed -i 's#Server=127.0.0.1#Server=$_ip#g' /etc/zabbix/zabbix-agent.confd
+sed -i 's#Hostname=Zabbix server#Hostname=$_host_name#g'
+
+systemctl restart zabbix-agent
+systemctl enable zabbix-agent
+
+echo -e "\033[92;1mZabbix-agent installed and configured, please add the host in your zabbix-server \033[Om"