mirror of
https://github.com/postmannen/ctrl.git
synced 2024-12-14 12:37:31 +00:00
fixed read messages from file, added helper scripts for ReqCli
This commit is contained in:
parent
d348ab156f
commit
57e074d210
5 changed files with 180 additions and 39 deletions
|
@ -233,7 +233,6 @@ func (s *server) readFolder() {
|
|||
|
||||
if event.Op == fsnotify.Create || event.Op == fsnotify.Chmod {
|
||||
fmt.Printf(" *** got *** : %v, op: %v\n", event.Name, event.Op)
|
||||
}
|
||||
|
||||
func() {
|
||||
fh, err := os.Open(event.Name)
|
||||
|
@ -283,6 +282,7 @@ func (s *server) readFolder() {
|
|||
}
|
||||
|
||||
}()
|
||||
}
|
||||
|
||||
case err, ok := <-watcher.Errors:
|
||||
if !ok {
|
||||
|
|
47
scripts/cliAshReadfolder.sh
Executable file
47
scripts/cliAshReadfolder.sh
Executable file
|
@ -0,0 +1,47 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "No toNode supplied"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "$2" ]; then
|
||||
echo "No cmd supplied"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
command=$2
|
||||
|
||||
IFS=',' read -r -a array <<<"$1"
|
||||
|
||||
function sendMessage() {
|
||||
cat >msg.yaml <<EOF
|
||||
[
|
||||
{
|
||||
"toNodes": ["${element}"],
|
||||
"method": "REQCliCommand",
|
||||
"methodArgs":
|
||||
[
|
||||
"/bin/ash",
|
||||
"-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
|
||||
sendMessage element command
|
||||
cp msg.yaml ./readfolder
|
||||
done
|
47
scripts/cliAshSocket.sh
Executable file
47
scripts/cliAshSocket.sh
Executable file
|
@ -0,0 +1,47 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "No toNode supplied"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "$2" ]; then
|
||||
echo "No cmd supplied"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
command=$2
|
||||
|
||||
IFS=',' read -r -a array <<<"$1"
|
||||
|
||||
function sendMessage() {
|
||||
cat >msg.yaml <<EOF
|
||||
[
|
||||
{
|
||||
"toNodes": ["${element}"],
|
||||
"method": "REQCliCommand",
|
||||
"methodArgs":
|
||||
[
|
||||
"/bin/ash",
|
||||
"-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
|
||||
sendMessage element command
|
||||
nc -U ./tmp/steward.sock <msg.yaml
|
||||
done
|
47
scripts/cliBashReadfolder.sh
Executable file
47
scripts/cliBashReadfolder.sh
Executable file
|
@ -0,0 +1,47 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "No toNode supplied"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "$2" ]; then
|
||||
echo "No cmd supplied"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
command=$2
|
||||
|
||||
IFS=',' read -r -a array <<<"$1"
|
||||
|
||||
function sendMessage() {
|
||||
cat >msg.yaml <<EOF
|
||||
[
|
||||
{
|
||||
"toNodes": ["${element}"],
|
||||
"method": "REQCliCommand",
|
||||
"methodArgs":
|
||||
[
|
||||
"/bin/bash",
|
||||
"-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
|
||||
sendMessage element command
|
||||
cp msg.yaml ./readfolder
|
||||
done
|
Loading…
Reference in a new issue