Skip to content

Instantly share code, notes, and snippets.

@brokendish
Created January 19, 2012 12:50
Show Gist options
  • Save brokendish/1639929 to your computer and use it in GitHub Desktop.
Save brokendish/1639929 to your computer and use it in GitHub Desktop.
denyhosts Unlock
#!/bin/bash
#---------------------------
#denyhosts Unlock
#
# perm1:IP-Address
#
# Brokendish
#---------------------------
#
echo '***************************************************'
echo '** denyhosts Unlock **'
echo '***************************************************'
#入力パラメータチェック1
if [ -z "$1" ]
then
echo "引数にIPアドレスを指定して!"
echo "ex) " $0 " IPアドレス"
exit
fi
#入力パラータがIPアドレスであること
if [ -z "`echo $1 |sed -e "/^[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}$/g"`" ]
then
#IPなので処理するよ!!
for i in /etc/hosts.deny /var/lib/denyhosts/*
do
echo "--------------------------------------------------"
echo "SelectFile-----:"$i
echo "deleteLine------------:"$1
sed -i -e "/$1/d" $i
echo "--------------------------------------------------"
cat $i
done
else
echo "IPアドレスじゃねーし!!"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment