fail2ban - Adapt to new sequencer functions
This commit is contained in:
@@ -7,44 +7,51 @@ toolConfLoc="$toolConfDir/jail.local"
|
|||||||
toolFilter="$toolConfDir/filter.d"
|
toolFilter="$toolConfDir/filter.d"
|
||||||
toolJails="$toolConfDir/jail.d"
|
toolJails="$toolConfDir/jail.d"
|
||||||
|
|
||||||
# Get script working directory
|
CONFIG_FILTER="${seq_dir:-}/filter.d"
|
||||||
# (when called from a different directory)
|
CONFIG_JAILS="${seq_dir:-}/jail.d"
|
||||||
WDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >>/dev/null 2>&1 && pwd )"
|
|
||||||
CONFIG=0
|
|
||||||
CONFIG_FILE_NAME="${toolName}.cfg"
|
|
||||||
CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example"
|
|
||||||
CONFIG_DIR="$WDIR/fail2ban"
|
|
||||||
CONFIG_FILTER="$CONFIG_DIR/filter.d"
|
|
||||||
CONFIG_JAILS="$CONFIG_DIR/jail.d"
|
|
||||||
|
|
||||||
#step_config() {
|
sq_aptOpt=
|
||||||
# echo "Called once before executing steps."
|
#sq_config=0
|
||||||
# ## e.g. to source a config file manually:
|
|
||||||
# #. "$CONFIG_FILE"
|
seq_config() {
|
||||||
# ## or to use sequencer api:
|
## Called once before executing steps.
|
||||||
# #initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE"
|
## e.g. to source a config file manually:
|
||||||
# #if [ $? -eq 0 ] ; then
|
#. "${seq_origin:?}/${seq_configName:?}"
|
||||||
# # CONFIG=1
|
|
||||||
# #fi
|
## or to use sequencer api with profile config file support:
|
||||||
#}
|
#if initSeqConfig -p "${seq_fileName:?}" "${seq_configTemplate:?}" ; then
|
||||||
|
|
||||||
|
## or to use sequencer api with global config file:
|
||||||
|
#if initSeqConfig "${seq_configName:?}" "${seq_configTemplate:?}" ; then
|
||||||
|
# sq_config=1
|
||||||
|
#else
|
||||||
|
# # End if no configuration file exists
|
||||||
|
# dry || return 1
|
||||||
|
#fi
|
||||||
|
|
||||||
|
## Apt cmdline option to suppress user interaction
|
||||||
|
interactive || sq_aptOpt="-y"
|
||||||
|
|
||||||
|
## Disable error checks if external scripts are used
|
||||||
|
## e.g. error on unbound variables
|
||||||
|
#disableErrorCheck
|
||||||
|
|
||||||
|
## Return of non zero value will abort the sequence
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
step_1_info() { echo "Install $toolName"; }
|
step_1_info() { echo "Install $toolName"; }
|
||||||
step_1_alias() { echo "install"; }
|
step_1_alias() { echo "install"; }
|
||||||
step_1() {
|
step_1() {
|
||||||
local aptOpt=
|
|
||||||
if quiet;then
|
|
||||||
aptOpt="-y"
|
|
||||||
fi
|
|
||||||
|
|
||||||
exe apt update
|
exe apt update
|
||||||
exe apt install $toolDeps $aptOpt
|
exe apt install ${toolDeps} ${sq_aptOpt}
|
||||||
}
|
}
|
||||||
|
|
||||||
step_2_info() { echo "Base jail configuration to use ufw"; }
|
step_2_info() { echo "Base jail configuration to use ufw"; }
|
||||||
step_2_alias() { echo "config"; }
|
step_2_alias() { echo "config"; }
|
||||||
step_2() {
|
step_2() {
|
||||||
echo " [I] Create local configuration";
|
info "Create local configuration";
|
||||||
addConf -f "$failConfLocal" "$toolConfLoc"
|
addConf -a "$failConfLocal" "$toolConfLoc"
|
||||||
exe service $toolName restart
|
exe service $toolName restart
|
||||||
}
|
}
|
||||||
failConfLocal="[DEFAULT]
|
failConfLocal="[DEFAULT]
|
||||||
@@ -57,9 +64,9 @@ step_3_info() { echo "Add basic ip-blacklist"; }
|
|||||||
step_3_alias() { echo "blacklist"; }
|
step_3_alias() { echo "blacklist"; }
|
||||||
step_3() {
|
step_3() {
|
||||||
echo " [I] Adding filter"
|
echo " [I] Adding filter"
|
||||||
addConf -s -f "$ipBlackListFilter" "$toolFilter/$(basename $ipBlackListFilter)"
|
addConf -s -f "$ipBlackListFilter" "$toolFilter/$(basename -- "$ipBlackListFilter")"
|
||||||
addConf -s -f "$ipBlackListJail" "$toolJails/$(basename $ipBlackListJail)"
|
addConf -s -f "$ipBlackListJail" "$toolJails/$(basename -- "$ipBlackListJail")"
|
||||||
addConf -s -f "$ipBlackList" "$toolConfDir/$(basename $ipBlackList)"
|
addConf -s -f "$ipBlackList" "$toolConfDir/$(basename -- "$ipBlackList")"
|
||||||
exe service $toolName restart
|
exe service $toolName restart
|
||||||
}
|
}
|
||||||
ipBlackList="$CONFIG_DIR/ip.blacklist"
|
ipBlackList="$CONFIG_DIR/ip.blacklist"
|
||||||
@@ -80,10 +87,12 @@ NOTES_EOF
|
|||||||
step_20_info() { echo "Install mailserver jail"; }
|
step_20_info() { echo "Install mailserver jail"; }
|
||||||
step_20_alias() { echo "mail"; }
|
step_20_alias() { echo "mail"; }
|
||||||
step_20() {
|
step_20() {
|
||||||
addConf -s -f "$mailJail" "$toolJails/$(basename $mailJail)"
|
addConf -s -f "$mailJail" "$toolJails/$(basename -- "$mailJail")"
|
||||||
exe service $toolName restart
|
exe service $toolName restart
|
||||||
}
|
}
|
||||||
mailJail="$CONFIG_JAILS/mail.conf"
|
mailJail="$CONFIG_JAILS/mail.conf"
|
||||||
|
|
||||||
|
# shellcheck disable=SC2034 # Appears unused
|
||||||
readonly sqr_minVersion=16
|
readonly sqr_minVersion=16
|
||||||
|
# shellcheck disable=SC1091 # Don't follow this source
|
||||||
. /usr/local/bin/sequencer.sh
|
. /usr/local/bin/sequencer.sh
|
||||||
|
Reference in New Issue
Block a user