aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDavid M. Syzdek <syzdek@bindlebinaries.com>2019-07-29 16:08:42 -0800
committerDavid M. Syzdek <syzdek@bindlebinaries.com>2019-07-29 16:11:02 -0800
commit152bc3a14d2b9719be3f132e80189796fa8c5fb9 (patch)
treeece278a0eba26b39992872253153ab7561cf6df0
parentbafb37d3cedcbcc7bb1d2b2ee32e45dbbd7ac7f3 (diff)
downloadbbfw-152bc3a14d2b9719be3f132e80189796fa8c5fb9.tar.gz
bbfw-152bc3a14d2b9719be3f132e80189796fa8c5fb9.tar.bz2
bbfw-152bc3a14d2b9719be3f132e80189796fa8c5fb9.tar.xz
bbfw-152bc3a14d2b9719be3f132e80189796fa8c5fb9.zip
Adding function to check config before running
-rwxr-xr-xsrc/bbfw.in44
1 files changed, 27 insertions, 17 deletions
diff --git a/src/bbfw.in b/src/bbfw.in
index 40fdcb8..e6f28d1 100755
--- a/src/bbfw.in
+++ b/src/bbfw.in
@@ -144,6 +144,30 @@ config_option()
144} 144}
145 145
146 146
147conftest()
148{
149 # quiet option
150 if test "x${FW_QUIET}" == "xno";then
151 unset FW_QUIET
152 elif test "x${FW_QUIET}" != "xyes";then
153 echo "invalid value for option 'quiet'" |$LOGGER
154 return 1
155 fi
156
157 # verbose option
158 if test "x${FW_VERBOSE}" == "xno";then
159 unset FW_VERBOSE
160 elif test "x${FW_VERBOSE}" != "xyes";then
161 echo "invalid value for verbose 'quiet'" |$LOGGER
162 return 1
163 else
164 FW_VERBOSE=-v
165 fi
166
167 return 0
168}
169
170
147dump() 171dump()
148{ 172{
149 ipset list |sed -e "s/^/ipset: /g" 173 ipset list |sed -e "s/^/ipset: /g"
@@ -458,23 +482,6 @@ FW_ORDER_IPTABLES="$( config_option order_iptables "${FW_ORDER_IPTABLES}" A-Z
458FW_ORDER_IPSETS="$( config_option order_ipsets "${FW_ORDER_IPSETS}" A-Z a-z )" 482FW_ORDER_IPSETS="$( config_option order_ipsets "${FW_ORDER_IPSETS}" A-Z a-z )"
459 483
460 484
461# checks and normalizes options
462if test "x${FW_QUIET}" == "xno";then
463 unset FW_QUIET
464elif test "x${FW_QUIET}" != "xyes";then
465 echo "${PROGRAM_NAME}: invalid value for option 'quiet'" 1>&2
466 exit 1
467fi
468if test "x${FW_VERBOSE}" == "xno";then
469 unset FW_VERBOSE
470elif test "x${FW_VERBOSE}" != "xyes";then
471 echo "${PROGRAM_NAME}: invalid value for verbose 'quiet'" 1>&2
472 exit 1
473else
474 FW_VERBOSE=-v
475fi
476
477
478case "$1" in 485case "$1" in
479 -h|--help) 486 -h|--help)
480 echo "Usage: ${PROGRAM_NAME} [ start | stop | restart | dump ]" 487 echo "Usage: ${PROGRAM_NAME} [ start | stop | restart | dump ]"
@@ -493,16 +500,19 @@ case "$1" in
493 500
494 'start') # "start" brings up all configured interfaces: 501 'start') # "start" brings up all configured interfaces:
495 echo "${PACKAGE_NAME} ${PACKAGE_VERSION}" | $LOGGER 502 echo "${PACKAGE_NAME} ${PACKAGE_VERSION}" | $LOGGER
503 conftest || exit 1
496 start 2>&1 | $LOGGER 504 start 2>&1 | $LOGGER
497 ;; 505 ;;
498 506
499 'stop') # "stop" takes down all configured interfaces: 507 'stop') # "stop" takes down all configured interfaces:
500 echo "${PACKAGE_NAME} ${PACKAGE_VERSION}" | $LOGGER 508 echo "${PACKAGE_NAME} ${PACKAGE_VERSION}" | $LOGGER
509 conftest || exit 1
501 stop 2>&1 | $LOGGER 510 stop 2>&1 | $LOGGER
502 ;; 511 ;;
503 512
504 'restart') # "restart" restarts the network: 513 'restart') # "restart" restarts the network:
505 echo "${PACKAGE_NAME} ${PACKAGE_VERSION}" | $LOGGER 514 echo "${PACKAGE_NAME} ${PACKAGE_VERSION}" | $LOGGER
515 conftest || exit 1
506 stop 2>&1 | $LOGGER 516 stop 2>&1 | $LOGGER
507 start 2>&1 | $LOGGER 517 start 2>&1 | $LOGGER
508 ;; 518 ;;