diff --git a/bin/srfirewall b/bin/srfirewall index 98c38bb..d32d3dc 100755 --- a/bin/srfirewall +++ b/bin/srfirewall @@ -19,7 +19,7 @@ # along with this program. If not, see . # Static config options, normally do not need to change -FW_VERSION="2.0" +FW_VERSION="2.0 PreAlpha 1" # Important directory locations FWPREFIX="/usr/local" @@ -47,6 +47,8 @@ if (( ${BASH_VERSINFO[0]} <= "2" )); then exit 1 fi + + # Swap out display_c command for dummy command if they don't want # output when command is run. if [ "${DisplayDetailedOutput}" == "yes" ]; then @@ -59,7 +61,7 @@ if [ "${DisplayDetailedOutput}" == "yes" ]; then display="true" fi -# Swap out display_c command for dummy command if they don't want +# Swap out debug command for dummy command if they don't want # debug output when command is run. if [ "${DisplayDebugInfo}" == "yes" ]; then if [ "${ColorizeOut}" == "yes" ]; then @@ -71,6 +73,23 @@ else debug="true" fi +# Parse command line args +while getopts "hfgv" opt; do + case $opt in + h) + show_help + exit 0 + ;; + v) + show_version + exit 0 + ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + ;; + esac +done + #if [ "$UID" != "0" ] && [ "${DebugOverride}" != "yes" ]; then # ${display} RED "You must be root to run this script." # exit 2 diff --git a/lib/display.inc b/lib/display.inc index 0d380dc..18d0730 100644 --- a/lib/display.inc +++ b/lib/display.inc @@ -85,8 +85,19 @@ function reset_color { # show_help # Show command line options help function show_help { - echo "Firewall/SOSDG ${FW_VERSION} - Brielle Bruns " - echo -e "\t--help\t\tShows this info" - echo -e "\t--flush\t\tFlushes all rules back to default ACCEPT" - echo -e "\t--generate-cache\tGenerate cached rule file" - } \ No newline at end of file + ${display} DEFAULT_COLOR "SRFirewall ${FW_VERSION}" + ${display} DEFAULT_COLOR "\n${0} -[fghv]\n" + ${display} DEFAULT_COLOR "\t-f\tFlushes all rules back to default ACCEPT" + ${display} DEFAULT_COLOR "\t-g\tGenerate cached rule files (not implemented yet)" + ${display} DEFAULT_COLOR "\t-h\tShows this help" + ${display} DEFAULT_COLOR "\t-v\tShow version" + } + + function show_version { + ${display} DEFAULT_COLOR "SRFirewall ${FW_VERSION}" + ${display} DEFAULT_COLOR "Written by: Brielle Bruns " + ${display} DEFAULT_COLOR "http://www.sosdg.org/freestuff/firewall" + ${display} DEFAULT_COLOR "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=" + ${display} DEFAULT_COLOR "Released under the GNU GPL Version 3" + ${display} DEFAULT_COLOR "https://www.gnu.org/licenses/gpl-3.0.txt" +} \ No newline at end of file