Skip to content

Commit

Permalink
adding fail2ban copying in configure script
Browse files Browse the repository at this point in the history
  • Loading branch information
mikegioia committed Dec 28, 2014
1 parent 69f916e commit 1b7d744
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 11 deletions.
11 changes: 11 additions & 0 deletions configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,16 @@ function copySshdConfig {
fi
}

## Copy over fail2ban config
function copyJailLocal {
if ! [[ -f "$basepath/conf/$profile/jail.local" ]] ; then
echo -e " - ${green}Copying${NC} jail.local"
cp $basepath/src/fail2ban_conf/jail.local $basepath/conf/$profile/jail.local
else
echo -e " - ${yellow}Skipping${NC} jail.local, file already exists"
fi
}

## Run the copy files scripts
function copyFiles {
echo -e "${green}Copying new configuration files${NC}"
Expand All @@ -222,6 +232,7 @@ function copyFiles {
copyRedis
copyMonit
copySshdConfig
copyJailLocal
}

## Finish
Expand Down
32 changes: 21 additions & 11 deletions scripts/fail2ban.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,28 @@ function installFail2ban {
fi
}

## Check if there's a local config file to update
if [[ -f "$basepath/conf/$profile/jail.local" ]] ; then
cp $basepath/conf/$profile/jail.local /etc/fail2ban/jail.local
fi
function copyConfigFiles {
## Check if there's a local config file to update
if [[ -f "$basepath/conf/$profile/jail.local" ]] ; then
echo -e "${green}Copying jail.local to /etc/fail2ban${NC}"
cp $basepath/conf/$profile/jail.local /etc/fail2ban/jail.local
else
echo -e "${yellow}No jail.local found, skipping${NC}"
fi

## Copy over configs if they're not there
if ! [[ -f "/etc/fail2ban/filter.d/nginx-dos.conf" ]] ; then
cp $basepath/src/fail2ban_conf/nginx-dos.conf /etc/fail2ban/filter.d/nginx-dos.conf
fi
## Copy over configs if they're not there
if ! [[ -f "/etc/fail2ban/filter.d/nginx-dos.conf" ]] ; then
cp $basepath/src/fail2ban_conf/nginx-dos.conf /etc/fail2ban/filter.d/nginx-dos.conf
fi
}

## Restart the service
service fail2ban restart
function promptRestart {
service fail2ban restart
}

echo 'Fail2Ban completed'
echo ''
promptInstall
installFail2ban
copyConfigFiles
promptRestart
exit 0

0 comments on commit 1b7d744

Please sign in to comment.