-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathodc-rp-example.sh
executable file
·52 lines (45 loc) · 1.54 KB
/
odc-rp-example.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env bash
# The plugin gets --res option as a first argument followed by a string.
# odc-rp-example --res "Resource description"
opt=$1
desc=$2
# Do some basic consistency check:
# * number of arguments is equal to 2
# * first argument is "--res"
if [[ "$#" -ne 2 || ${opt} != "--res" ]]; then
echo "Illegal arguments. Usage: odc-rp-example --res \"Resource description\"."
exit 1
fi
# Generate a sample DDS SSH config file
# In this sample example we assume that resource description containes either "config1" or "config2".
# Based on this string we create a static DDS SSH configuration.
# In a real case a resource description can be rather complicated, for example, in JSON or XML format.
sshConfigSample=""
if [[ ${desc} = "config1" ]]; then
sshConfigSample="
@bash_begin@
@bash_end@
wn_sample_1, localhost, , ~/tmp/wn_dds, 10
wn_sample_2, node.gsi.de, , ~/tmp/wn_dds, 10
"
elif [[ ${desc} = "config2" ]]; then
sshConfigSample="
@bash_begin@
source MyScript.sh
@bash_end@
wn_data_1, localhost, , ~/tmp/wn_dds, 20
wn_data_2, node101.gsi.de, , ~/tmp/wn_dds, 20
wn_data_3, node202.gsi.de, , ~/tmp/wn_dds, 20
"
else
echo "Illegal resource description. Use \"config1\" or \"config2\""
exit 1
fi
# Save a sample DDS SSH config file
sshConfigFile="my_dds_ssh_config.cfg"
echo "${sshConfigSample}" > ${sshConfigFile}
# For SSH configuration the required fields are <rms> and <configFile> and
# Print output to stdout
echo "<rms>ssh</rms>
<configFile>${sshConfigFile}</configFile>
exit 0