[packages/haproxy] sysvinit: unified verbose configtest wrapper
glen
glen at pld-linux.org
Tue Jan 3 06:11:45 CET 2017
commit f788cd15a707fcefa62dc97c2715df2dae3d87be
Author: Elan Ruusamäe <glen at delfi.ee>
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
More information about the pld-cvs-commit
mailing list