Commit c573ca0c authored by UltimateByte's avatar UltimateByte Committed by GitHub
Browse files

rework for before actions

parent 1162e3e4
......@@ -132,9 +132,15 @@ fn_evaluate(){
# Execute an action before proceeding
fn_actionbefore(){
if [ -n "${actionbefore}" ]; then
if [ -n "${actionbefore}" ]&&[ "${harm}" == "1" ]&&[ -z "${actiontaken}" ]; then
fn_logecho "[ACTION] Applying actionbefore: ${actionbefore}"
${actionbefore}
actiontaken="1"
refresh="1"
else
# Misc var to tell that an action has been taken
actiontaken="1"
fn_logecho "[ACTION] Refreshing info ${pid}"
fi
}
......@@ -155,13 +161,18 @@ fn_action(){
fn_logecho "[INFO] Actual : Name: ${pidname}\tUser: ${piduser}\tPath: ${pidcommand}"
# Take the "before" action
fn_actionbefore
# If a before action has been done, refresh info
if [ -n "${refresh}" ]; then
unset refresh
fn_define_vars
fn_evaluate
fn_action
else
# Kill the app
fn_logecho "[ACTION] Killing PID ${pid}"
kill -9 "${pid}"
# Reset harm for future tests
unset harm
# Misc var to tell that an action has been taken
actiontaken="1"
# Misc var to count how many time we ran this
count=$((count+1))
# If $count is greater or equel to $maxruns; then end there
......@@ -173,6 +184,7 @@ fn_action(){
sleep "${sleeptime}"
fn_run_functions
fi
fi
elif [ "${actiontaken}" == "1" ]; then
fn_logecho "[OK] The process on port ${portcheck} now meets requirements"
fn_mail_alert
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment