Compare commits
No commits in common. "73fff32758b9d2b9660d4ba8fabe9a989cff9297" and "76907b87390cbd50c65c3aa841c1d4611ffabcd7" have entirely different histories.
73fff32758
...
76907b8739
@ -17,10 +17,9 @@ note="\e[95m"
|
||||
|
||||
### functions
|
||||
|
||||
function copyFailure {
|
||||
function copyFailureure {
|
||||
echo
|
||||
echo -e "${err}There was a problem backing-up/copying the configuration" \
|
||||
"files."
|
||||
echo -e "${err}There was a problem backing up your current configuration."
|
||||
echo -e "This suggests some kind of permissions error. Please remedy this" \
|
||||
"and rerun"
|
||||
echo -e "this script."
|
||||
@ -61,7 +60,8 @@ echo "(testing: base-dir is: ${F2B_DIR})"
|
||||
|
||||
### user info preamble
|
||||
echo
|
||||
echo -e "${note}--------------------------------------------------------------------------------${normal}"
|
||||
echo -e "${note}------------------------------------------------------------" \
|
||||
"--------------------${normal}"
|
||||
echo -e "${info}This script will copy customized configuration files to your" \
|
||||
"fail2ban"
|
||||
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}" \
|
||||
"https://mytechiethoughts.com${info} to understand"
|
||||
echo -e "how to customize these template files.${normal}"
|
||||
echo -e "${note}--------------------------------------------------------------------------------${normal}"
|
||||
echo -e "${note}------------------------------------------------------------" \
|
||||
"--------------------${normal}"
|
||||
echo
|
||||
|
||||
|
||||
### copy template files
|
||||
# note: prefixing cp with '\' to override any alias settings
|
||||
# copy .local files
|
||||
if [ ! "$(\cp --force --backup=simple --suffix=.original \
|
||||
etc/fail2ban/*.local "${F2B_DIR}/")" ]; then
|
||||
if [ "$(\cp --force --backup=simple --suffix=.original \
|
||||
etc/fail2ban/*.local "${F2B_DIR}/")" -ne 0 ]; then
|
||||
copyFailure 'general config files (.local)'
|
||||
fi
|
||||
echo -e "${info}Copy general configuration files${normal} -- ${ok}[OK]${normal}"
|
||||
|
||||
# copy action configuration files
|
||||
if [ ! "$(\cp --force --backup=simple --suffix=.original \
|
||||
etc/fail2ban/action.d/* "${F2B_DIR}/action.d/")" ]; then
|
||||
if [ "$(\cp --force --backup=simple --suffix=.original \
|
||||
etc/fail2ban/action.d/* "${F2B_DIR}/action.d/")" -ne 0 ]; then
|
||||
copyFailure 'action files'
|
||||
fi
|
||||
echo -e "${info}Copy action configuration files${normal} -- ${ok}[OK]${normal}"
|
||||
|
||||
# copy filter configuration files
|
||||
if [ ! "$(\cp --force --backup=simple --suffix=.original \
|
||||
etc/fail2ban/filter.d/* "${F2B_DIR}/filter.d/")" ]; then
|
||||
if [ "$(\cp --force --backup=simple --suffix=.original \
|
||||
etc/fail2ban/filter.d/* "${F2B_DIR}/filter.d/")" -ne 0 ]; then
|
||||
copyFailure 'filter files'
|
||||
fi
|
||||
echo -e "${info}Copy filter configuration files${normal} -- ${ok}[OK]${normal}"
|
||||
|
||||
# copy jail configuration files
|
||||
if [ ! "$(\cp --force --backup=simple --suffix=.original \
|
||||
etc/fail2ban/jail.d/* "${F2B_DIR}/jail.d/")" ]; then
|
||||
if [ "$(\cp --force --backup=simple --suffix=.original \
|
||||
etc/fail2ban/jail.d/* "${F2B_DIR}/jail.d/")" -ne 0 ]; then
|
||||
copyFailure 'jail files'
|
||||
fi
|
||||
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
|
||||
echo
|
||||
echo -e "${note}--------------------------------------------------------------------------------${normal}"
|
||||
echo -e "${note}------------------------------------------------------------" \
|
||||
"--------------------${normal}"
|
||||
echo -e "${ok}Script operations completed successfully!"
|
||||
echo
|
||||
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" \
|
||||
"${note}files over the modified"
|
||||
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
|
||||
|
||||
|
||||
### exit gracefully
|
||||
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.
|
||||
exit 0
|
Loading…
Reference in New Issue
Block a user