Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
HaiSoft (public)
Wrong Listener Killer
Commits
c573ca0c
Commit
c573ca0c
authored
May 29, 2017
by
UltimateByte
Committed by
GitHub
May 29, 2017
Browse files
rework for before actions
parent
1162e3e4
Changes
1
Hide whitespace changes
Inline
Side-by-side
wlk.sh
View file @
c573ca0c
...
...
@@ -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,23 +161,29 @@ fn_action(){
fn_logecho
"[INFO] Actual : Name:
${
pidname
}
\t
User:
${
piduser
}
\t
Path:
${
pidcommand
}
"
# Take the "before" action
fn_actionbefore
# 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
if
[
"
${
count
}
"
-ge
"
${
maxruns
}
"
]
;
then
fn_logecho
"[WARNING] Exiting because the loop has reached the maximum
${
maxruns
}
runs"
fn_mail_alert
# Otherwise, let's run it again
# If a before action has been done, refresh info
if
[
-n
"
${
refresh
}
"
]
;
then
unset
refresh
fn_define_vars
fn_evaluate
fn_action
else
sleep
"
${
sleeptime
}
"
fn_run_functions
# Kill the app
fn_logecho
"[ACTION] Killing PID
${
pid
}
"
kill
-9
"
${
pid
}
"
# Reset harm for future tests
unset
harm
# Misc var to count how many time we ran this
count
=
$((
count+1
))
# If $count is greater or equel to $maxruns; then end there
if
[
"
${
count
}
"
-ge
"
${
maxruns
}
"
]
;
then
fn_logecho
"[WARNING] Exiting because the loop has reached the maximum
${
maxruns
}
runs"
fn_mail_alert
# Otherwise, let's run it again
else
sleep
"
${
sleeptime
}
"
fn_run_functions
fi
fi
elif
[
"
${
actiontaken
}
"
==
"1"
]
;
then
fn_logecho
"[OK] The process on port
${
portcheck
}
now meets requirements"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment