v-delete-firewall-rule 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/bash
  2. # info: delete firewall rule
  3. # options: RULE
  4. #
  5. # The function deletes firewall rule.
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Importing system variables
  10. source /etc/profile
  11. # Argument definition
  12. rule=$1
  13. # Includes
  14. source $VESTA/func/main.sh
  15. source $VESTA/conf/vesta.conf
  16. #----------------------------------------------------------#
  17. # Verifications #
  18. #----------------------------------------------------------#
  19. check_args '1' "$#" 'RULE'
  20. is_format_valid 'rule'
  21. is_system_enabled "$FIREWALL_SYSTEM" 'FIREWALL_SYSTEM'
  22. is_object_valid '../../data/firewall/rules' 'RULE' "$rule"
  23. #----------------------------------------------------------#
  24. # Action #
  25. #----------------------------------------------------------#
  26. # Deleting rule
  27. sed -i "/RULE='$rule' /d" $VESTA/data/firewall/rules.conf
  28. # Updating system firewall
  29. $BIN/v-update-firewall
  30. #----------------------------------------------------------#
  31. # Vesta #
  32. #----------------------------------------------------------#
  33. # Logging
  34. log_event "$OK" "$ARGUMENTS"
  35. exit