You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

103 lines
2.9 KiB

  1. #!/bin/bash
  2. # By Brielle Bruns <bruns@2mbit.com>
  3. # URL: http://www.sosdg.org/freestuff/firewall
  4. # License: GPLv3
  5. #
  6. # Copyright (C) 2009 - 2014 Brielle Bruns
  7. # Copyright (C) 2009 - 2014 The Summit Open Source Development Group
  8. #
  9. # This program is free software: you can redistribute it and/or modify
  10. # it under the terms of the GNU General Public License as published by
  11. # the Free Software Foundation, either version 3 of the License, or
  12. # (at your option) any later version.
  13. #
  14. # This program is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. # GNU General Public License for more details.
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. # ANSI color sequences
  21. BLUE="\e[34m"
  22. GREEN="\e[32m"
  23. RED="\e[31m"
  24. YELLOW="\e[33m"
  25. PURPLE="\e[35m"
  26. AQUA="\e[36m"
  27. WHITE="\e[97m"
  28. GREY="\e[37m"
  29. DEFAULT_COLOR="\e[39m"
  30. # display_c $COLOR $TEXT BOOL(YN)
  31. # $COLOR being bash colors
  32. # $TEXT being what to output (make sure to put " " around text)
  33. # BOOL being (Y or N) to do newline at end or not
  34. function display_c {
  35. unset COLOR_CODE TEXT NEWLINE
  36. DEFAULT_COLOR="\E[39m"
  37. COLOR_CODE=`pick_color $1`
  38. TEXT="$2"
  39. if [ "$3" == "N" ]; then
  40. NEWLINE="-n"
  41. fi
  42. echo -e ${NEWLINE} "${COLOR_CODE}${TEXT}${DEFAULT_COLOR}"
  43. }
  44. # Monochrome version of above
  45. function display_m {
  46. unset TEXT NEWLINE
  47. TEXT="$2"
  48. if [ "$3" == "N" ]; then
  49. NEWLINE="-n"
  50. fi
  51. echo -e $NEWLINE "$TEXT"
  52. }
  53. # pick_color $COLOR
  54. # returns appropriate color codes for use in display_c and such
  55. function pick_color {
  56. case $1 in
  57. BLUE) COLOR="\E[34m" ;;
  58. GREEN) COLOR="\E[32m" ;;
  59. RED) COLOR="\E[31m" ;;
  60. YELLOW) COLOR="\E[33m" ;;
  61. PURPLE) COLOR="\E[35m" ;;
  62. AQUA) COLOR="\E[36m" ;;
  63. WHITE) COLOR="\E[1m" ;;
  64. GREY) COLOR="\E[37m" ;;
  65. *) COLOR="\E[37m" ;;
  66. esac
  67. echo "${COLOR}"
  68. }
  69. # reset_color
  70. function reset_color {
  71. unset NEWLINE
  72. DEFAULT_COLOR="\E[39m"
  73. if [ "$1" == "N" ]; then
  74. NEWLINE="-n"
  75. fi
  76. echo ${NEWLINE} -e "${DEFAULT_COLOR}"
  77. }
  78. # show_help
  79. # Show command line options help
  80. function show_help {
  81. ${display} DEFAULT_COLOR "SRFirewall ${FW_VERSION}"
  82. ${display} DEFAULT_COLOR "\n${0} -[fghv]\n"
  83. ${display} DEFAULT_COLOR "\t-f\tFlushes all rules back to default ACCEPT"
  84. ${display} DEFAULT_COLOR "\t-g\tGenerate cached rule files (not implemented yet)"
  85. ${display} DEFAULT_COLOR "\t-h\tShows this help"
  86. ${display} DEFAULT_COLOR "\t-v\tShow version"
  87. }
  88. function show_version {
  89. ${display} DEFAULT_COLOR "SRFirewall ${FW_VERSION}"
  90. ${display} DEFAULT_COLOR "Written by: Brielle Bruns <bruns@2mbit.com>"
  91. ${display} DEFAULT_COLOR "http://www.sosdg.org/freestuff/firewall"
  92. ${display} DEFAULT_COLOR "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="
  93. ${display} DEFAULT_COLOR "Released under the GNU GPL Version 3"
  94. ${display} DEFAULT_COLOR "https://www.gnu.org/licenses/gpl-3.0.txt"
  95. }