diff --git a/scripts/install_fail2ban.sh b/scripts/install_fail2ban.sh index 0111406..7a8075a 100755 --- a/scripts/install_fail2ban.sh +++ b/scripts/install_fail2ban.sh @@ -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 diff --git a/scripts/remove_fail2ban.sh b/scripts/remove_fail2ban.sh index 8f5d6c5..9dcacb5 100755 --- a/scripts/remove_fail2ban.sh +++ b/scripts/remove_fail2ban.sh @@ -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 diff --git a/scripts/utils.sh b/scripts/utils.sh index fa4be30..66fd12e 100755 --- a/scripts/utils.sh +++ b/scripts/utils.sh @@ -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