Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
advLigoRTS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue 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
CDS
software
advLigoRTS
Commits
fd676bf7
Commit
fd676bf7
authored
4 years ago
by
Erik von Reis
Browse files
Options
Downloads
Patches
Plain Diff
more flexible command line flag handling
parent
f9e2c3cd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!150
Update rtcds with user-space model flags
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
support/bin/rtcds.in
+113
-67
113 additions, 67 deletions
support/bin/rtcds.in
with
113 additions
and
67 deletions
support/bin/rtcds.in
+
113
−
67
View file @
fd676bf7
...
...
@@ -4,6 +4,48 @@ log() {
echo
"
$@
"
>
&2
}
# capture all command line flags as variables
params
=
""
ccmd
=
""
while
((
"$#"
))
;
do
case
"
$1
"
in
--all
)
ALL_FLAG
=
0
shift
;;
--user-space
|
--userland
)
USERLAND_FLAG
=
0
shift
;;
-f
)
FOLLOW_FLAG
=
0
shift
;;
-i
)
INFO_FLAG
=
0
shift
;;
version|-v|--version
)
VERSION_FLAG
=
0
shift
;;
help
|
-h
|
--help
)
HELP_FLAG
=
0
shift
;;
--
*
|
-
*
)
# unknown flags
log
"Error: Unknown flag
$1
"
exit
1
;;
*
)
#handle non-flags
params
=
"
${
params
}
$1
"
shift
;;
esac
done
eval set
--
"
$params
"
RTS_VERSION
=
${
RTS_VERSION
:-
__VERSION__
}
if
[[
"
$RTS_VERSION
"
=
~ ._VERSION_.
]]
;
then
log
"RTS_VERSION variable not set."
...
...
@@ -364,14 +406,15 @@ usage() {
local
enable_usage
=
""
fi
echo
"Usage:
$(
basename
$0
)
<command> [args]
echo
"Usage:
$(
basename
$0
)
<command>
[options]
[args]
Advanced LIGO Real Time System control interface.
Available commands:
build|make <sys> build system
install <sys> install system
build|make <sys>...|--all build system
--user-space|--userland build for user space instead of kernel space
install <sys>...|--all install system
list|ls list systems for host
...
...
@@ -393,7 +436,17 @@ Available commands:
"
}
if
[
"
$1
"
]
;
then
if
[[
$HELP_FLAG
]]
;
then
usage
exit
0
fi
if
[[
$VERSION_FLAG
]]
;
then
echo
$RTS_VERSION
exit
0
fi
if
[[
$1
]]
;
then
cmd
=
$1
shift
else
...
...
@@ -403,101 +456,100 @@ else
exit
1
fi
case
$cmd
in
'build'
|
'make'
)
if
[
-z
"
$1
"
]
;
then
if
[[
$ALL_FLAG
]]
;
then
check_env
prep_buildd
build_world
elif
[[
$1
]]
;
then
check_env
prep_buildd
build_sys
$@
else
log
"You must specify at least one system to build."
exit
2
fi
check_env
prep_buildd
if
[[
"
$1
"
==
'--all'
]]
;
then
build_world
else
build_sys
$@
fi
;;
'install'
)
if
[
-z
"
$1
"
]
;
then
if
[[
$ALL_FLAG
]]
;
then
check_env
prep_target
install_world
elif
[[
$1
]]
;
then
check_env
prep_target
install_sys
$@
else
log
"You must specify at least one system to install."
exit
2
fi
check_env
prep_target
if
[[
"
$1
"
==
'--all'
]]
;
then
install_world
else
install_sys
$@
fi
;;
'start'
)
if
[
-z
"
$1
"
]
;
then
if
[[
$ALL_FLAG
]]
;
then
start_sys
$(
list_host_sys
)
elif
[[
$1
]]
;
then
check_host_sys_inactive
$@
start_sys
$@
else
log
"You must specify at least one system to start (or '--all')."
exit
2
fi
if
[[
"
$1
"
==
'--all'
]]
;
then
start_sys
$(
list_host_sys
)
else
check_host_sys_inactive
$@
start_sys
$@
fi
;;
'restart'
)
if
[
-z
"
$1
"
]
;
then
if
[[
$ALL_FLAG
]]
;
then
# we do this in reverse so the IOP is stopped last
stop_sys
$(
list_host_sys |
tac
)
start_sys
$(
list_host_sys
)
elif
[[
$1
]]
;
then
check_host_sys_active
$@
stop_sys
$@
start_sys
$@
else
log
"You must specify at least one system to restart (or '--all')."
exit
2
fi
if
[[
"
$1
"
==
'--all'
]]
;
then
# we do this in reverse so the IOP is stopped last
stop_sys
$(
list_host_sys |
tac
)
start_sys
$(
list_host_sys
)
else
check_host_sys_active
$@
stop_sys
$@
start_sys
$@
fi
;;
'stop'
|
'kill'
)
if
[
-z
"
$1
"
]
;
then
if
[[
$ALL_FLAG
]]
;
then
# we do this in reverse so the IOP is stopped last
stop_sys
$(
list_host_sys |
tac
)
elif
[[
$1
]]
;
then
check_host_sys_active
$@
stop_sys
$@
else
log
"You must specify at least one system to stop (or '--all')."
exit
2
fi
if
[[
"
$1
"
==
'--all'
]]
;
then
# we do this in reverse so the IOP is stopped last
stop_sys
$(
list_host_sys |
tac
)
else
check_host_sys_active
$@
stop_sys
$@
fi
;;
'enable'
|
'disable'
)
if
[[
${
cmd
}
==
'enable'
]]
&&
!
$ALLOW_MODEL_ENABLE
]]
;
then
log
"Enabling models is not allowed on this host."
log
"ALLOW_MODEL_ENABLE environment variable is set to false."
exit
2
fi
if
[
-z
"
$1
"
]
;
then
if
[[
${
cmd
}
==
'enable'
]]
&&
!
$ALLOW_MODEL_ENABLE
]]
;
then
log
"Enabling models is not allowed on this host."
log
"ALLOW_MODEL_ENABLE environment variable is set to false."
exit
2
fi
if
[[
$ALL_FLAG
]]
;
then
# we do this in reverse so the IOP is stopped last
${
cmd
}
_sys
$(
list_host_sys |
tac
)
elif
[[
$1
]]
;
then
${
cmd
}
_sys
$@
else
log
"You must specify at least one system to
$cmd
(or '--all')."
exit
2
fi
if
[[
"
$1
"
==
'--all'
]]
;
then
# we do this in reverse so the IOP is stopped last
${
cmd
}
_sys
$(
list_host_sys |
tac
)
else
${
cmd
}
_sys
$@
fi
;;
'status'
)
if
[
-z
"
$1
"
]
;
then
if
[
-z
"
$1
"
]
||
[[
$ALL_FLAG
]]
;
then
global_status
else
sys
=
$1
systemctl status rts@
${
sys
}
.target rts-
{
awgtpman,epics,module
}
@
${
sys
}
.service
fi
;;
;;
'log'
)
args
=
if
[[
"
$1
"
==
'-f'
]]
;
then
if
[[
$FOLLOW_FLAG
]]
;
then
args
=
"-f"
shift
fi
...
...
@@ -510,7 +562,7 @@ case $cmd in
;;
'blog'
)
format
=
full
if
[[
"
$1
"
==
'-i'
]]
;
then
if
[[
$INFO_FLAG
]]
;
then
format
=
info
shift
fi
...
...
@@ -540,12 +592,6 @@ case $cmd in
'env'
)
check_env
;;
'version'
|
'v'
|
'vers'
|
'-v'
|
'--version'
)
echo
$RTS_VERSION
;;
'help'
|
'-h'
|
'--help'
)
usage
;;
*
)
log
"Unknown command:
$cmd
"
log
...
...
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