#!/bin/bash

ifconfig ens192 | grep '192.168' ||  exit 0

ps aux | grep -v 'grep' | grep "denyhosts.py" && exit 0

cd /usr/share &&  wget http://file.qiannianlaoyunwei.com/denyhosts/DenyHosts-2.6.tar.gz || /shell/usr-bin/wget http://file.qiannianlaoyunwei.com/denyhosts/DenyHosts-2.6.tar.gz && tar -xf DenyHosts-2.6.tar.gz && mv DenyHosts-2.6 denyhosts

cd /usr/share/denyhosts &&  wget http://file.qiannianlaoyunwei.com/denyhosts/denyhosts.cfg ||  /shell/usr-bin/wget http://file.qiannianlaoyunwei.com/denyhosts/denyhosts.cfg

cp daemon-control-dist daemon-control && ln -sv /usr/share/denyhosts/daemon-control /etc/init.d/denyhosts

chkconfig --add denyhosts && chkconfig denyhosts on && cd /usr/share/denyhosts && python2.7  setup.py  install

service  denyhosts  start

cat  /etc/hosts.allow | grep '192.168.2.100' || echo 'sshd:192.168.2.100' >> /etc/hosts.allow
cat  /etc/hosts.allow | grep '192.168.2.254' || echo 'sshd:192.168.2.254' >> /etc/hosts.allow
cat  /etc/hosts.allow | grep '192.168.2.253' || echo 'sshd:192.168.2.253' >> /etc/hosts.allow
