fw 686 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/sh
  2. FW_LIBDIR=/lib/firewall
  3. . /etc/functions.sh
  4. . ${FW_LIBDIR}/fw.sh
  5. case "$(type fw)" in
  6. *function) ;;
  7. *) exit 255;;
  8. esac
  9. usage() {
  10. echo $0 "<command>" "<family>" "<table>" "<chain>" "<target>" "{" "<rules>" "}"
  11. exit 0
  12. }
  13. cmd=$1
  14. shift
  15. case "$cmd" in
  16. --help|help) usage ;;
  17. start|stop|reload|restart)
  18. . ${FW_LIBDIR}/core.sh
  19. fw_$cmd
  20. exit $?
  21. ;;
  22. esac
  23. fam=$1
  24. shift
  25. case "$fam" in
  26. ip)
  27. fam=i
  28. if [ $# -gt 2 ]; then
  29. for p in $(seq 2 $(($# - 1))); do
  30. if eval "[ \$$p == '}' ]"; then
  31. fam=I
  32. break
  33. fi
  34. done
  35. fi ;;
  36. ip4) fam=4 ;;
  37. ip6) fam=6 ;;
  38. arp) fam=a ;;
  39. eth) fam=e ;;
  40. -*) exec $0 $cmd ${fam##*-} "$@" ;;
  41. esac
  42. fw "$cmd" "$fam" "$@"
  43. exit $?