Advertisement
Guest User

Untitled

a guest
May 25th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #!/bin/bash
  2. # vi: noexpandtab ts=4 sw=4 ff=unix fenc=utf-8 ft=sh
  3.  
  4. function error() {
  5. printf "\e[31mERROR: %s\e[m\n" "${1:-'unknown'}"
  6. exit 1
  7. }
  8.  
  9. if ! which firewall-cmd &> /dev/null; then
  10. error "firewall-cmd not found."
  11. fi
  12. if ! firewall-cmd --version &> /dev/null; then
  13. error "You need to be root to perform this command."
  14. fi
  15.  
  16. for z in $(firewall-cmd --get-active-zones | grep -v ':'); do
  17. firewall-cmd --info-zone $z | grep -Ev '^[\s]*$|:[\s ]+$'
  18.  
  19. for s in $(firewall-cmd --list-services --zone=$z); do
  20. firewall-cmd --info-service $s | grep -Ev '^[\s]*$|:[\s ]+$' | sed -r 's/(.*)/ \1/g'
  21. done
  22. printf "\n"
  23. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement