#!/bin/sh

# This script will eventually unban everyone in f2b-sshd
# but I need people in jail to test the next part. For 
# now, it'll list the IPs of the banned folks so I can
# unban them more easily.

run_user=$(id -u)
if [ "$run_user" -eq 0 ]; then
  r="$(/sbin/iptables -L f2b-sshd -n | grep REJECT)" 
  if [ -n "$r" ]; then
    printf "%s" "$r" | awk '{print $4}' | xargs /usr/bin/fail2ban-client set sshd unbanip
  fi
else
  exec sudo "$0" "$@"
fi
