Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
xxx-R6-1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
synApps_6_1_Working
xxx-R6-1
Commits
36249ce2
Commit
36249ce2
authored
6 years ago
by
prjemian
Browse files
Options
Downloads
Patches
Plain Diff
#16 indentation resolved - all spaces now
needs testing before closing this issue
parent
3234d66d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
iocBoot/iocxxx/softioc/xxx.sh
+92
-96
92 additions, 96 deletions
iocBoot/iocxxx/softioc/xxx.sh
with
92 additions
and
96 deletions
iocBoot/iocxxx/softioc/xxx.sh
+
92
−
96
View file @
36249ce2
...
...
@@ -43,24 +43,23 @@ PS=ps
SNAME
=
${
BASH_SOURCE
:-
$0
}
SELECTION
=
$1
if
[
-z
"
$IOC_STARTUP_DIR
"
]
then
if
[
-z
"
$IOC_STARTUP_DIR
"
]
;
then
# If no startup dir is specified, use the directory above the script's directory
IOC_STARTUP_DIR
=
`
dirname
${
SNAME
}
`
/..
IOC_CMD
=
"../../bin/
${
EPICS_HOST_ARCH
}
/
${
IOC_BINARY
}
st.cmd.Linux"
IOC_CMD
=
"../../bin/
${
EPICS_HOST_ARCH
}
/
${
IOC_BINARY
}
st.cmd.Linux"
else
IOC_CMD
=
"
${
IOC_STARTUP_DIR
}
/../../bin/
${
EPICS_HOST_ARCH
}
/
${
IOC_BINARY
}
${
IOC_STARTUP_DIR
}
/st.cmd.Linux"
IOC_CMD
=
"
${
IOC_STARTUP_DIR
}
/../../bin/
${
EPICS_HOST_ARCH
}
/
${
IOC_BINARY
}
${
IOC_STARTUP_DIR
}
/st.cmd.Linux"
fi
#!${ECHO} ${IOC_STARTUP_DIR}
#####################################################################
screenpid
()
{
if
[
-z
${
SCREEN_PID
}
]
;
then
${
ECHO
}
else
${
ECHO
}
" in a screen session (pid=
${
SCREEN_PID
}
)"
fi
if
[
-z
${
SCREEN_PID
}
]
;
then
${
ECHO
}
else
${
ECHO
}
" in a screen session (pid=
${
SCREEN_PID
}
)"
fi
}
checkpid
()
{
...
...
@@ -71,61 +70,59 @@ checkpid() {
if
[
"
${
IOC_PID
}
"
!=
""
]
;
then
# Assume the IOC is down until proven otherwise
IOC_DOWN
=
1
IOC_DOWN
=
1
# At least one instance of the IOC binary is running;
# Find the binary that is associated with this script/IOC
# At least one instance of the IOC binary is running;
# Find the binary that is associated with this script/IOC
for
pid
in
${
IOC_PID
}
;
do
BIN_CWD
=
`
${
READLINK
}
/proc/
${
pid
}
/cwd
`
IOC_CWD
=
`
${
READLINK
}
-f
${
IOC_STARTUP_DIR
}
`
if
[
"
$BIN_CWD
"
==
"
$IOC_CWD
"
]
;
then
# The IOC is running; the binary with PID=$pid is the IOC that was run from $IOC_STARTUP_DIR
IOC_PID
=
${
pid
}
IOC_DOWN
=
0
SCREEN_PID
=
""
if
[
"
${
GET_SCREEN_PID
}
"
==
"YES"
]
then
# Get the PID of the parent of the IOC (shell or screen)
P_PID
=
`
${
PS
}
-p
${
IOC_PID
}
-o
ppid
=
`
# Get the PID of the grandparent of the IOC (sshd, screen, or ???)
GP_PID
=
`
${
PS
}
-p
${
P_PID
}
-o
ppid
=
`
#!${ECHO} "P_PID=${P_PID}, GP_PID=${GP_PID}"
# Get the screen PIDs
S_PIDS
=
`
${
PGREP
}
screen
`
for
s_pid
in
${
S_PIDS
}
do
#!${ECHO} ${s_pid}
if
[
"
${
s_pid
}
"
==
"
${
P_PID
}
"
]
;
then
SCREEN_PID
=
${
s_pid
}
break
fi
if
[
"
${
s_pid
}
"
==
"
${
GP_PID
}
"
]
;
then
SCREEN_PID
=
${
s_pid
}
break
fi
done
fi
break
#else
# ${ECHO} "PATHS are different"
# ${ECHO} ${BIN_CWD}
# ${ECHO} ${IOC_CWD}
fi
done
BIN_CWD
=
`
${
READLINK
}
/proc/
${
pid
}
/cwd
`
IOC_CWD
=
`
${
READLINK
}
-f
${
IOC_STARTUP_DIR
}
`
if
[
"
$BIN_CWD
"
==
"
$IOC_CWD
"
]
;
then
# The IOC is running; the binary with PID=$pid is the IOC that was run from $IOC_STARTUP_DIR
IOC_PID
=
${
pid
}
IOC_DOWN
=
0
SCREEN_PID
=
""
if
[
"
${
GET_SCREEN_PID
}
"
==
"YES"
]
;
then
# Get the PID of the parent of the IOC (shell or screen)
P_PID
=
`
${
PS
}
-p
${
IOC_PID
}
-o
ppid
=
`
# Get the PID of the grandparent of the IOC (sshd, screen, or ???)
GP_PID
=
`
${
PS
}
-p
${
P_PID
}
-o
ppid
=
`
#!${ECHO} "P_PID=${P_PID}, GP_PID=${GP_PID}"
# Get the screen PIDs
S_PIDS
=
`
${
PGREP
}
screen
`
for
s_pid
in
${
S_PIDS
}
;
do
#!${ECHO} ${s_pid}
if
[
"
${
s_pid
}
"
==
"
${
P_PID
}
"
]
;
then
SCREEN_PID
=
${
s_pid
}
break
fi
if
[
"
${
s_pid
}
"
==
"
${
GP_PID
}
"
]
;
then
SCREEN_PID
=
${
s_pid
}
break
fi
done
fi
break
#else
# ${ECHO} "PATHS are different"
# ${ECHO} ${BIN_CWD}
# ${ECHO} ${IOC_CWD}
fi
done
else
# IOC is not running
IOC_DOWN
=
1
IOC_DOWN
=
1
fi
return
${
IOC_DOWN
}
...
...
@@ -134,19 +131,19 @@ checkpid() {
start
()
{
if
checkpid
;
then
${
ECHO
}
-n
"
${
IOC_NAME
}
is already running (pid=
${
IOC_PID
}
)"
screenpid
screenpid
else
${
ECHO
}
"Starting
${
IOC_NAME
}
"
cd
${
IOC_STARTUP_DIR
}
# Run xxx inside a screen session
${
SCREEN
}
-dm
-S
${
IOC_NAME
}
-h
5000
${
IOC_CMD
}
# Run xxx inside a screen session
${
SCREEN
}
-dm
-S
${
IOC_NAME
}
-h
5000
${
IOC_CMD
}
fi
}
stop
()
{
if
checkpid
;
then
${
ECHO
}
"Stopping
${
IOC_NAME
}
(pid=
${
IOC_PID
}
)"
${
KILL
}
${
IOC_PID
}
${
KILL
}
${
IOC_PID
}
else
${
ECHO
}
"
${
IOC_NAME
}
is not running"
fi
...
...
@@ -169,10 +166,10 @@ status() {
console
()
{
if
checkpid
;
then
${
ECHO
}
"Connecting to
${
IOC_NAME
}
's screen session"
# The -r flag will only connect if no one is attached to the session
#!${SCREEN} -r ${IOC_NAME}
# The -x flag will connect even if someone is attached to the session
${
SCREEN
}
-x
${
IOC_NAME
}
# The -r flag will only connect if no one is attached to the session
#!${SCREEN} -r ${IOC_NAME}
# The -x flag will connect even if someone is attached to the session
${
SCREEN
}
-x
${
IOC_NAME
}
else
${
ECHO
}
"
${
IOC_NAME
}
is not running"
fi
...
...
@@ -181,21 +178,21 @@ console() {
run
()
{
if
checkpid
;
then
${
ECHO
}
-n
"
${
IOC_NAME
}
is already running (pid=
${
IOC_PID
}
)"
screenpid
screenpid
else
${
ECHO
}
"Starting
${
IOC_NAME
}
"
cd
${
IOC_STARTUP_DIR
}
# Run xxx outside of a screen session, which is helpful for debugging
${
IOC_CMD
}
# Run xxx outside of a screen session, which is helpful for debugging
${
IOC_CMD
}
fi
}
start_medm
()
{
${
IOC_STARTUP_DIR
}
/../../start_MEDM_xxx
${
IOC_STARTUP_DIR
}
/../../start_MEDM_xxx
}
start_caqtdm
()
{
${
IOC_STARTUP_DIR
}
/../../start_caQtDM_xxx
${
IOC_STARTUP_DIR
}
/../../start_caQtDM_xxx
}
usage
()
{
...
...
@@ -204,46 +201,45 @@ usage() {
#####################################################################
if
[
!
-d
${
IOC_STARTUP_DIR
}
]
then
if
[
!
-d
${
IOC_STARTUP_DIR
}
]
;
then
${
ECHO
}
"Error:
${
IOC_STARTUP_DIR
}
doesn't exist."
${
ECHO
}
"IOC_STARTUP_DIR in
${
SNAME
}
needs to be corrected."
else
case
${
SELECTION
}
in
start
)
start
;;
start
;;
stop
|
kill
)
stop
;;
stop
;;
restart
)
restart
;;
restart
;;
status
)
status
;;
status
;;
console
)
console
;;
;;
run
)
run
;;
medm
)
start_medm
;;
caqtdm
)
start_caqtdm
;;
;;
medm
)
start_medm
;;
caqtdm
)
start_caqtdm
;;
*
)
usage
;;
usage
;;
esac
fi
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