commit f788cd15a707fcefa62dc97c2715df2dae3d87be
Author: Elan Ruusamäe <[email protected]>
Date:   Tue Jan 3 07:01:08 2017 +0200

    sysvinit: unified verbose configtest wrapper

 haproxy.init | 35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)
---
diff --git a/haproxy.init b/haproxy.init
index febeb8d..070d453 100755
--- a/haproxy.init
+++ b/haproxy.init
@@ -27,8 +27,41 @@ else
        exit 0
 fi
 
+# configtest itself
+# must return non-zero if check failed
+# output is discarded if checkconfig is ran without details
+configtest() {
+       /usr/sbin/haproxy -q -c -f /etc/haproxy/haproxy.cfg
+       return $?
+}
+
+# wrapper for configtest
 checkconfig() {
-       /usr/sbin/haproxy -q -c -f /etc/haproxy/haproxy.cfg || exit 1
+       local details=${1:-0}
+
+       if [ $details = 1 ]; then
+               # run config test and display report (status action)
+               show "Checking %s configuration" "HA-Proxy"; busy
+               local out
+               out=$(configtest 2>&1)
+               RETVAL=$?
+               if [ $RETVAL = 0 ]; then
+                       ok
+               else
+                       fail
+               fi
+               [ "$out" ] && echo >&2 "$out"
+       else
+               # run config test and abort with nice message if failed
+               # (for actions checking status before action).
+               configtest >/dev/null 2>&1
+               RETVAL=$?
+               if [ $RETVAL != 0 ]; then
+                       show "Checking %s configuration" "HA-Proxy"; fail
+                       nls 'Configuration test failed. See details with %s 
"checkconfig"' $0
+                       exit $RETVAL
+               fi
+       fi
 }
 
 start() {
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/haproxy.git/commitdiff/58bad708c5277045c7ad9192d2a049500544df71

_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to