Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RadioObservatory
LOFAR
Commits
a7811e2a
Commit
a7811e2a
authored
5 years ago
by
Jan David Mol
Browse files
Options
Downloads
Patches
Plain Diff
SW-610
: Fix getting pid in swlevel, by using a dedicated function. Works on ccu and lcu now.
parent
ded9ddfb
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
MAC/APL/APLCommon/src/swlevel
+19
-13
19 additions, 13 deletions
MAC/APL/APLCommon/src/swlevel
with
19 additions
and
13 deletions
MAC/APL/APLCommon/src/swlevel
+
19
−
13
View file @
a7811e2a
...
...
@@ -42,10 +42,16 @@ ETCDIR=$LOFARROOT/etc
OPERBINDIR
=
/opt/operations/bin
LEVELTABLE
=
${
ETCDIR
}
/swlevel.conf
# pidof is in /usr/sbin, usually; this is not added to PATH for non-interactive logins
# (in /etc/profile) so explicitly find location of executable pidof now.
PIDOF
=
`
whereis
-b
pidof |
awk
'{print $2}'
`
PGREP
=
pgrep
# Return the PID of a process or script
function
getpid
{
PROGRAM
=
"
$1
"
# use "pgrep -f" to get the PID of scripts.
# only use this as a fall-back when "pgrep" itself returns nothing,
# since "pgrep -f" returns false positives for non-scripts.
pgrep
$PROGRAM
||
pgrep
-f
$PROGRAM
}
# Counter to indicate if 48V reset has been attempted
has_been_reset
=
0
...
...
@@ -282,7 +288,7 @@ start_prog()
fi
# Check if program is already running
$PGREP
-f
${
prog
}
1>/dev/null 2>&1
getpid
${
prog
}
1>/dev/null 2>&1
if
[
$?
-ne
0
]
;
then
curdate
=
`
date
+%Y%m%dT%H%M%S
`
# WinCC needs special treatment
...
...
@@ -349,7 +355,7 @@ stop_prog()
fi
# get processlist
$PGREP
-f
${
prog
}
1>/dev/null 2>&1
getpid
${
prog
}
1>/dev/null 2>&1
if
[
$?
-ne
0
]
;
then
return
fi
...
...
@@ -370,7 +376,7 @@ stop_prog()
fi
# first try normal kill
for
pid
in
`
$PGREP
-f
${
prog
}
`
for
pid
in
`
getpid
${
prog
}
`
do
echo
"Softly killing
${
prog
}
(
${
pid
}
)"
$asroot
kill
$pid
1>/dev/null 2>&1
...
...
@@ -378,7 +384,7 @@ stop_prog()
done
# when normal kill did not work, kill is with -9
for
pid
in
`
$PGREP
-f
${
prog
}
`
for
pid
in
`
getpid
${
prog
}
`
do
echo
"Hard killing
${
prog
}
(
${
pid
}
)"
$asroot
kill
-9
$pid
1>/dev/null 2>&1
...
...
@@ -386,7 +392,7 @@ stop_prog()
done
# if user0 or lofarsys, try normal kill as root
for
pid
in
`
$PGREP
-f
${
prog
}
`
for
pid
in
`
getpid
${
prog
}
`
do
if
[
"
$user
"
==
"user0"
-o
"
$user
"
==
"lofarsys"
]
;
then
sudo kill
$pid
1>/dev/null 2>&1
...
...
@@ -395,7 +401,7 @@ stop_prog()
done
# if user0 or lofarsys, try hard kill as root
for
pid
in
`
$PGREP
-f
${
prog
}
`
for
pid
in
`
getpid
${
prog
}
`
do
if
[
"
$user
"
==
"user0"
-o
"
$user
"
==
"lofarsys"
]
;
then
sudo kill
-9
$pid
1>/dev/null 2>&1
...
...
@@ -404,7 +410,7 @@ stop_prog()
done
# if still alive, write a message
for
pid
in
`
$PGREP
-f
${
prog
}
`
for
pid
in
`
getpid
${
prog
}
`
do
echo
-n
"Could not kill
${
prog
}
(
${
pid
}
); "
if
[
"
$user
"
==
"user0"
-o
"
$user
"
==
"lofarsys"
]
;
then
...
...
@@ -464,9 +470,9 @@ status_prog()
# find out the processID of the possibly (running) process
obsid
=()
pid_user
=()
$PGREP
-f
${
prog
}
1>/dev/null 2>&1
getpid
${
prog
}
1>/dev/null 2>&1
if
[
$?
-eq
0
]
;
then
pid
=(
`
$PGREP
-f
${
prog
}
`
)
pid
=(
`
getpid
${
prog
}
`
)
i
=
0
for
apid
in
${
pid
[@]
}
do
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment