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-26 11:00:22 +00:00
|
|
|
cat >msg-"$element".json <<EOF
|
2023-01-06 07:18:20 +00:00
|
|
|
[
|
|
|
|
{
|
|
|
|
"toNodes": ["${element}"],
|
2024-11-19 02:48:42 +00:00
|
|
|
"method": "cliCommand",
|
2023-01-06 07:18:20 +00:00
|
|
|
"methodArgs":
|
|
|
|
[
|
2023-01-09 08:10:52 +00:00
|
|
|
"${shell}",
|
2023-01-06 07:18:20 +00:00
|
|
|
"-c",
|
|
|
|
'echo "--------------------${element}----------------------" && ${command}',
|
|
|
|
],
|
2024-11-19 02:48:42 +00:00
|
|
|
"replyMethod": "fileAppend",
|
2023-01-06 07:18:20 +00:00
|
|
|
"retryWait": 5,
|
2023-05-30 03:46:02 +00:00
|
|
|
"ACKTimeout": 30,
|
2023-01-06 07:18:20 +00:00
|
|
|
"retries": 1,
|
2023-05-30 03:46:02 +00:00
|
|
|
"replyACKTimeout": 30,
|
2023-01-06 07:18:20 +00:00
|
|
|
"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-26 11:00:22 +00:00
|
|
|
cp msg-"$element".json ./readfolder
|
2023-01-06 07:18:20 +00:00
|
|
|
done
|