I was trying a lot.
It seems, that a Terminal is necessary to execute a su command to reboot the PC.
The jdownloader User has no sudo privileges.
The hard part is, that the Script which has to be executed, must be "injected" by the Eventscripter via "echo" command. That is a hard nut to crack with a lot of special characters and new lines...
I try to inject this Script:
Code:
#!/usr/bin/expect -f
#Usage: script.sh cmd user pass
set cmd [lindex $argv 0];
set user [lindex $argv 1];
set pass [lindex $argv 2];
log_user 0
spawn su -c $cmd - $user
expect "Password: "
log_user 1
send "$pass\r"
expect "$ "
with this EventScripter Script:
Code:
[ {
"eventTrigger" : "ON_NEW_CRAWLER_JOB",
"enabled" : true,
"name" : null,
"script" : "// Restart remote (JD) server via myjd WebUI\n// Trigger: New Crawler Job\n\nif (job.text == \"restartserver\") {\n alert(callSync(\"/bin/bash\", \"-c\", \"echo -e \\\"#!\\/usr\\/bin\\/expect -f\\r\\n#Usage: script.sh cmd user pass\\r\\n\\r\\nset cmd [lindex $argv 0];\\r\\nset user [lindex $argv 1];\\r\\nset pass [lindex $argv 2];\\r\\n\\r\\nlog_user 0\\r\\nspawn su -c $cmd - $user\\r\\nexpect \\\"Password: \\\"\\r\\nlog_user 1\\r\\nsend \\\"$pass\\\\r\\\"\\r\\nexpect \\\"$ \\\"\\\" > /tmp/test.sh\"));\n}",
"eventTriggerSettings" : {
"isSynchronous" : false
},
"id" : 1529571752984
}]
But if I try to show the content of "/tmp/test.sh" with "cat" with this Script:
Code:
[ {
"eventTrigger" : "ON_NEW_CRAWLER_JOB",
"enabled" : true,
"name" : null,
"script" : "// Restart remote (JD) server via myjd WebUI\n// Trigger: New Crawler Job\n\nif (job.text == \"restartserver\") {\n alert(callSync(\"/bin/bash\", \"-c\", \"cat /tmp/test.sh\"));\n}",
"eventTriggerSettings" : {
"isSynchronous" : false
},
"id" : 1529571752984
}]
I get only the characters of the expected Content, no new Lines, no quotas, nothing.
I am not sure if this is a limitation of the Alert-Window which give me the message.
If I execute the /tmp/test.sh Script, I get a lot of syntax errors in nearly every line of the Script. It looks like the new line (\\r\\n) seems to work.