#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?sm)^\s+(?:re)?start.*?(haproxy_check).*?;;"
Local $sString = "case "$1" in" & @CRLF & _
" start)" & @CRLF & _
" echo -n "Starting haproxy "" & @CRLF & _
" ## Start daemon with startproc(8). If this fails" & @CRLF & _
" ## the return value is set appropriately by startproc." & @CRLF & _
" haproxy_check" & @CRLF & _
" /sbin/startproc $HAPROXY_BIN -D -f $HAPROXY_CONF -p $HAPROXY_PID" & @CRLF & _
" # Remember status and be verbose" & @CRLF & _
" rc_status -v" & @CRLF & _
" ;;" & @CRLF & _
" stop)" & @CRLF & _
" echo -n "Shutting down haproxy "" & @CRLF & _
" ## Stop daemon with killproc(8) and if this fails" & @CRLF & _
" ## killproc sets the return value according to LSB." & @CRLF & _
"" & @CRLF & _
" /sbin/killproc -TERM $HAPROXY_BIN" & @CRLF & _
"" & @CRLF & _
" # this is additional forcing kill command to ensure that all processes are stopped." & @CRLF & _
" /usr/bin/killall -9 $HAPROXY_BIN || true" & @CRLF & _
" # Remember status and be verbose" & @CRLF & _
" rc_status -v" & @CRLF & _
" ;;" & @CRLF & _
" try-restart|condrestart)" & @CRLF & _
" ## Do a restart only if the service was active before." & @CRLF & _
" ## Note: try-restart is now part of LSB (as of 1.9)." & @CRLF & _
" ## RH has a similar command named condrestart." & @CRLF & _
" if test "$1" = "condrestart"; then" & @CRLF & _
" echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"" & @CRLF & _
" fi" & @CRLF & _
" $0 status" & @CRLF & _
" if test $? = 0; then" & @CRLF & _
" # we us reload here for a graceful restart during update" & @CRLF & _
" $0 reload" & @CRLF & _
" else" & @CRLF & _
" rc_reset # Not running is not a failure." & @CRLF & _
" fi" & @CRLF & _
" # Remember status and be quiet" & @CRLF & _
" rc_status" & @CRLF & _
" ;;" & @CRLF & _
" restart)" & @CRLF & _
" ## Stop the service and regardless of whether it was" & @CRLF & _
" ## running or not, start it again." & @CRLF & _
" $0 stop" & @CRLF & _
" $0 start" & @CRLF & _
" haproxy_check" & @CRLF & _
" # Remember status and be quiet" & @CRLF & _
" rc_status" & @CRLF & _
" ;;" & @CRLF & _
" check)" & @CRLF & _
" ## Stop the service and regardless of whether it was" & @CRLF & _
" ## running or not, start it again." & @CRLF & _
" echo -n "Checking config of haproxy "" & @CRLF & _
" haproxy_check" & @CRLF & _
" rc_status -v" & @CRLF & _
" ;;" & @CRLF & _
" reload|force-reload)" & @CRLF & _
" ## Like force-reload, but if daemon does not support" & @CRLF & _
" ## signaling, do nothing (!)" & @CRLF & _
"" & @CRLF & _
" haproxy_check" & @CRLF & _
" # If it supports signaling:" & @CRLF & _
" echo -n "Reload service haproxy "" & @CRLF & _
" $HAPROXY_BIN -p $HAPROXY_PID -D -f $HAPROXY_CONF -sf $(cat $HAPROXY_PID)" & @CRLF & _
" rc_status -v" & @CRLF & _
" ;;" & @CRLF & _
" status)" & @CRLF & _
" echo -n "Checking for service haproxy "" & @CRLF & _
" ## Check status with checkproc(8), if process is running" & @CRLF & _
" ## checkproc will return with exit status 0." & @CRLF & _
"" & @CRLF & _
" # Return value is slightly different for the status command:" & @CRLF & _
" # 0 - service up and running" & @CRLF & _
" # 1 - service dead, but /var/run/ pid file exists" & @CRLF & _
" # 2 - service dead, but /var/lock/ lock file exists" & @CRLF & _
" # 3 - service not running (unused)" & @CRLF & _
" # 4 - service status unknown :-(" & @CRLF & _
" # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)" & @CRLF & _
"" & @CRLF & _
" # NOTE: checkproc returns LSB compliant status values." & @CRLF & _
" /sbin/checkproc $HAPROXY_BIN" & @CRLF & _
" # NOTE: rc_status knows that we called this init script with" & @CRLF & _
" # "status" option and adapts its messages accordingly." & @CRLF & _
" rc_status -v" & @CRLF & _
" ;;" & @CRLF & _
" probe)" & @CRLF & _
" ## Optional: Probe for the necessity of a reload, print out the" & @CRLF & _
" ## argument to this init script which is required for a reload." & @CRLF & _
" ## Note: probe is not (yet) part of LSB (as of 1.9)" & @CRLF & _
"" & @CRLF & _
" test $HAPROXY_CONF -nt $HAPROXY_PID && echo reload" & @CRLF & _
" ;;" & @CRLF & _
" *)" & @CRLF & _
" echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"" & @CRLF & _
" exit 1" & @CRLF & _
" ;;" & @CRLF & _
"esac"
Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH)
Local $aFullArray[0]
For $i = 0 To UBound($aArray) -1
_ArrayConcatenate($aFullArray, $aArray[$i])
Next
$aArray = $aFullArray
; Present the entire match result
_ArrayDisplay($aArray, "Result")
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm