2023-01-06 07:18:20 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
if [ -z "$1" ]; then
|
|
|
|
echo "No toNode supplied"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ -z "$2" ]; then
|
2023-01-09 08:10:52 +00:00
|
|
|
echo "No shell path supplied"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ -z "$3" ]; then
|
2023-01-06 07:18:20 +00:00
|
|
|
echo "No cmd supplied"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-01-09 08:10:52 +00:00
|
|
|
nodes=$1
|
|
|
|
shell=$2
|
|
|
|
command=$3
|
2023-01-06 07:18:20 +00:00
|
|
|
|
2023-01-09 08:10:52 +00:00
|
|
|
IFS=',' read -r -a array <<<"$nodes"
|
2023-01-06 07:18:20 +00:00
|
|
|
|
|
|
|
function sendMessage() {
|
2023-01-10 05:56:01 +00:00
|
|
|
cat >msg-"$element".yaml <<EOF
|
2023-01-06 07:18:20 +00:00
|
|
|
[
|
|
|
|
{
|
|
|
|
"toNodes": ["${element}"],
|
|
|
|
"method": "REQCliCommand",
|
|
|
|
"methodArgs":
|
|
|
|
[
|
2023-01-09 08:10:52 +00:00
|
|
|
"${shell}",
|
2023-01-06 07:18:20 +00:00
|
|
|
"-c",
|
|
|
|
'echo "--------------------${element}----------------------" && ${command}',
|
|
|
|
],
|
|
|
|
"replyMethod": "REQToFileAppend",
|
|
|
|
"retryWait": 5,
|
|
|
|
"ACKTimeout": 10,
|
|
|
|
"retries": 1,
|
|
|
|
"replyACKTimeout": 10,
|
|
|
|
"replyRetries": 1,
|
|
|
|
"methodTimeout": 10,
|
|
|
|
"replyMethodTimeout": 10,
|
|
|
|
"directory": "./data/",
|
|
|
|
"fileName": "debug.log",
|
|
|
|
},
|
|
|
|
]
|
|
|
|
EOF
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for element in "${array[@]}"; do
|
2023-01-09 08:10:52 +00:00
|
|
|
sendMessage element "$command"
|
2023-01-10 05:56:01 +00:00
|
|
|
cp msg-"$element".yaml ./readfolder
|
2023-01-06 07:18:20 +00:00
|
|
|
done
|