Update fail2ban installation

This commit is contained in:
Edi Septriyanto
2024-04-19 20:10:22 +07:00
parent 693ca341aa
commit a1e7d140ea
3 changed files with 25 additions and 7 deletions

View File

@@ -75,11 +75,19 @@ function init_fail2ban_install() {
if curl -sLI "${fail2ban_download_link}" | grep -q "HTTP/[.12]* [2].."; then
run wget "${fail2ban_download_link}" -O fail2ban.tar.gz && \
run tar -zxf fail2ban.tar.gz && \
run cd fail2ban-*/ && \
run cd fail2ban-*/
# Convert to Python3 codebase
run python -m pip install --upgrade 2to3 && \
run ./fail2ban-2to3 && \
run python setup.py install && \
run python -m venv /opt/fail2ban/ && \
run /opt/fail2ban/bin/pip install --upgrade pip setuptools cffi 2to3 && \
#run ln -sf /opt/fail2ban/bin/2to3 /usr/local/bin/2to3 && \
#run ./fail2ban-2to3 && \
run /opt/fail2ban/bin/python setup.py install && \
run ln -sf /opt/fail2ban/bin/fail2ban-client /usr/local/bin/fail2ban-client && \
run ln -sf /opt/fail2ban/bin/fail2ban-server /usr/local/bin/fail2ban-server && \
run ln -sf /opt/fail2ban/bin/fail2ban-regex /usr/local/bin/fail2ban-regex && \
run ln -sf /opt/fail2ban/bin/fail2ban-testcases /usr/local/bin/fail2ban-testcases && \
run ln -sf /opt/fail2ban/bin/python /usr/local/bin/fail2ban-python && \
run cp files/debian-initd /etc/init.d/fail2ban && \
run update-rc.d fail2ban defaults
fi

View File

@@ -33,7 +33,11 @@ function init_fail2ban_removal() {
run dpkg --purge fail2ban
else
info "Fail2ban package not found, possibly installed from source."
run rm -f /usr/bin/fail2ban-*
run unlink /usr/local/bin/fail2ban-client && \
run unlink /usr/local/bin/fail2ban-server && \
run unlink /usr/local/bin/fail2ban-regex && \
run unlink /usr/local/bin/fail2ban-testcases && \
run unlink /usr/local/bin/fail2ban-python
fi
[ -f /etc/systemd/system/multi-user.target.wants/fail2ban.service ] && \
@@ -57,7 +61,13 @@ function init_fail2ban_removal() {
fi
if [[ "${REMOVE_FAIL2BAN_CONFIG}" == y* || "${REMOVE_FAIL2BAN_CONFIG}" == Y* ]]; then
[ -d /etc/fail2ban/ ] && run rm -fr /etc/fail2ban/
if [ -d /etc/fail2ban/ ]; then
run rm -fr /etc/fail2ban/
fi
if [ -d /opt/fail2ban/ ]; then
run rm -fr /opt/fail2ban/
fi
echo "All configuration files deleted permanently."
fi

View File

@@ -113,7 +113,7 @@ function requires_root() {
exit 1
else
#echo "Switching to root user to run installer script."
sudo -E "$0" "$@"
sudo -E -H "$0" "$@"
exit 0
fi
fi