From 30f38a09a13bc23991756386496ad5fa35d02afe Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Sun, 8 Apr 2018 00:22:44 +0200 Subject: [PATCH] added zabbix agent install, some fix --- bin/fail2ban.sh | 6 +++--- bin/firewall.sh | 8 ++++---- bin/knockd.sh | 8 ++++---- bin/misc.sh | 6 +++--- bin/zabbix.sh | 37 +++++++++++++++++++++++++++++++++++++ 5 files changed, 51 insertions(+), 14 deletions(-) create mode 100644 bin/zabbix.sh diff --git a/bin/fail2ban.sh b/bin/fail2ban.sh index a1c13db..681fd55 100755 --- a/bin/fail2ban.sh +++ b/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" diff --git a/bin/firewall.sh b/bin/firewall.sh index da0ee28..8c28c9a 100755 --- a/bin/firewall.sh +++ b/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" diff --git a/bin/knockd.sh b/bin/knockd.sh index 53a2028..a37bb79 100755 --- a/bin/knockd.sh +++ b/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 diff --git a/bin/misc.sh b/bin/misc.sh index bb5025a..128cca4 100755 --- a/bin/misc.sh +++ b/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" diff --git a/bin/zabbix.sh b/bin/zabbix.sh new file mode 100644 index 0000000..a4e9eab --- /dev/null +++ b/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"