Compare commits
No commits in common. "73fff32758b9d2b9660d4ba8fabe9a989cff9297" and "76907b87390cbd50c65c3aa841c1d4611ffabcd7" have entirely different histories.
73fff32758
...
76907b8739
@ -17,10 +17,9 @@ note="\e[95m"
|
|||||||
|
|
||||||
### functions
|
### functions
|
||||||
|
|
||||||
function copyFailure {
|
function copyFailureure {
|
||||||
echo
|
echo
|
||||||
echo -e "${err}There was a problem backing-up/copying the configuration" \
|
echo -e "${err}There was a problem backing up your current configuration."
|
||||||
"files."
|
|
||||||
echo -e "This suggests some kind of permissions error. Please remedy this" \
|
echo -e "This suggests some kind of permissions error. Please remedy this" \
|
||||||
"and rerun"
|
"and rerun"
|
||||||
echo -e "this script."
|
echo -e "this script."
|
||||||
@ -61,7 +60,8 @@ echo "(testing: base-dir is: ${F2B_DIR})"
|
|||||||
|
|
||||||
### user info preamble
|
### user info preamble
|
||||||
echo
|
echo
|
||||||
echo -e "${note}--------------------------------------------------------------------------------${normal}"
|
echo -e "${note}------------------------------------------------------------" \
|
||||||
|
"--------------------${normal}"
|
||||||
echo -e "${info}This script will copy customized configuration files to your" \
|
echo -e "${info}This script will copy customized configuration files to your" \
|
||||||
"fail2ban"
|
"fail2ban"
|
||||||
echo -e "configuration directory. It will backup any existing files with the" \
|
echo -e "configuration directory. It will backup any existing files with the" \
|
||||||
@ -73,36 +73,37 @@ echo -e "${info}Please ensure you have reviewed the ${note}README${info} in" \
|
|||||||
echo -e "associated wiki or the blog post at${note}" \
|
echo -e "associated wiki or the blog post at${note}" \
|
||||||
"https://mytechiethoughts.com${info} to understand"
|
"https://mytechiethoughts.com${info} to understand"
|
||||||
echo -e "how to customize these template files.${normal}"
|
echo -e "how to customize these template files.${normal}"
|
||||||
echo -e "${note}--------------------------------------------------------------------------------${normal}"
|
echo -e "${note}------------------------------------------------------------" \
|
||||||
|
"--------------------${normal}"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
|
|
||||||
### copy template files
|
### copy template files
|
||||||
# note: prefixing cp with '\' to override any alias settings
|
# note: prefixing cp with '\' to override any alias settings
|
||||||
# copy .local files
|
# copy .local files
|
||||||
if [ ! "$(\cp --force --backup=simple --suffix=.original \
|
if [ "$(\cp --force --backup=simple --suffix=.original \
|
||||||
etc/fail2ban/*.local "${F2B_DIR}/")" ]; then
|
etc/fail2ban/*.local "${F2B_DIR}/")" -ne 0 ]; then
|
||||||
copyFailure 'general config files (.local)'
|
copyFailure 'general config files (.local)'
|
||||||
fi
|
fi
|
||||||
echo -e "${info}Copy general configuration files${normal} -- ${ok}[OK]${normal}"
|
echo -e "${info}Copy general configuration files${normal} -- ${ok}[OK]${normal}"
|
||||||
|
|
||||||
# copy action configuration files
|
# copy action configuration files
|
||||||
if [ ! "$(\cp --force --backup=simple --suffix=.original \
|
if [ "$(\cp --force --backup=simple --suffix=.original \
|
||||||
etc/fail2ban/action.d/* "${F2B_DIR}/action.d/")" ]; then
|
etc/fail2ban/action.d/* "${F2B_DIR}/action.d/")" -ne 0 ]; then
|
||||||
copyFailure 'action files'
|
copyFailure 'action files'
|
||||||
fi
|
fi
|
||||||
echo -e "${info}Copy action configuration files${normal} -- ${ok}[OK]${normal}"
|
echo -e "${info}Copy action configuration files${normal} -- ${ok}[OK]${normal}"
|
||||||
|
|
||||||
# copy filter configuration files
|
# copy filter configuration files
|
||||||
if [ ! "$(\cp --force --backup=simple --suffix=.original \
|
if [ "$(\cp --force --backup=simple --suffix=.original \
|
||||||
etc/fail2ban/filter.d/* "${F2B_DIR}/filter.d/")" ]; then
|
etc/fail2ban/filter.d/* "${F2B_DIR}/filter.d/")" -ne 0 ]; then
|
||||||
copyFailure 'filter files'
|
copyFailure 'filter files'
|
||||||
fi
|
fi
|
||||||
echo -e "${info}Copy filter configuration files${normal} -- ${ok}[OK]${normal}"
|
echo -e "${info}Copy filter configuration files${normal} -- ${ok}[OK]${normal}"
|
||||||
|
|
||||||
# copy jail configuration files
|
# copy jail configuration files
|
||||||
if [ ! "$(\cp --force --backup=simple --suffix=.original \
|
if [ "$(\cp --force --backup=simple --suffix=.original \
|
||||||
etc/fail2ban/jail.d/* "${F2B_DIR}/jail.d/")" ]; then
|
etc/fail2ban/jail.d/* "${F2B_DIR}/jail.d/")" -ne 0 ]; then
|
||||||
copyFailure 'jail files'
|
copyFailure 'jail files'
|
||||||
fi
|
fi
|
||||||
echo -e "${info}Copy jail configuration files${normal} -- ${ok}[OK]${normal}"
|
echo -e "${info}Copy jail configuration files${normal} -- ${ok}[OK]${normal}"
|
||||||
@ -110,7 +111,8 @@ echo -e "${info}Copy jail configuration files${normal} -- ${ok}[OK]${normal}"
|
|||||||
|
|
||||||
### user post-amble
|
### user post-amble
|
||||||
echo
|
echo
|
||||||
echo -e "${note}--------------------------------------------------------------------------------${normal}"
|
echo -e "${note}------------------------------------------------------------" \
|
||||||
|
"--------------------${normal}"
|
||||||
echo -e "${ok}Script operations completed successfully!"
|
echo -e "${ok}Script operations completed successfully!"
|
||||||
echo
|
echo
|
||||||
echo -e "${info}You can now customize the template files if/as you desire." \
|
echo -e "${info}You can now customize the template files if/as you desire." \
|
||||||
@ -123,19 +125,10 @@ echo
|
|||||||
echo -e "${note}To revert your configuration, simply copy the ${lit}.original" \
|
echo -e "${note}To revert your configuration, simply copy the ${lit}.original" \
|
||||||
"${note}files over the modified"
|
"${note}files over the modified"
|
||||||
echo -e "files. For example, ${lit}cp jail.local.original jail.local${normal}"
|
echo -e "files. For example, ${lit}cp jail.local.original jail.local${normal}"
|
||||||
echo -e "${note}--------------------------------Script--Complete--------------------------------${normal}"
|
echo -e "${note}--------------------------------Script--Complete------------" \
|
||||||
|
"--------------------${normal}"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
|
|
||||||
### exit gracefully
|
### exit gracefully
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
|
|
||||||
### error code summary
|
|
||||||
# 1: fail2ban executable file could not be found -- fail2ban likely not
|
|
||||||
# installed
|
|
||||||
# 2: script not run as ROOT (needed to avoid any permissions issues)
|
|
||||||
# 3: invalid fail2ban configuration directory provided by user
|
|
||||||
# 99: internal testing error code, should *not* appear in releases
|
|
||||||
# 100: error copying files to fail2ban configuration directory and/or making
|
|
||||||
# simultaneous backup copies of any exisitng files.
|
|
||||||
|
Loading…
Reference in New Issue
Block a user