first commit
This commit is contained in:
commit
752a38cb84
27
add-system-script.sh
Executable file
27
add-system-script.sh
Executable file
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
DEBUG="0"
|
||||
|
||||
set -x
|
||||
ROUTEROS_HOST="$1"
|
||||
USERNAME="$2"
|
||||
PASSWORD="$3"
|
||||
|
||||
SCRIPT_NAME="$4"
|
||||
|
||||
SCRIPT_FILENAME="$5"
|
||||
|
||||
if [ ! -z "${SCRIPT_NAME}" ]
|
||||
then
|
||||
|
||||
DATA=$( ruby text-file-to-json.rb ${SCRIPT_NAME} ${SCRIPT_FILENAME} )
|
||||
ADD_RES=$(\
|
||||
curl -q -k -u ${USERNAME}:${PASSWORD} -X POST "https://${ROUTEROS_HOST}/rest/system/script/add" \
|
||||
-H "content-type: application/json" \
|
||||
--data "${DATA}" \
|
||||
)
|
||||
echo "${ADD_RES}"
|
||||
fi
|
||||
|
||||
|
||||
set +x
|
3
script.txt
Normal file
3
script.txt
Normal file
@ -0,0 +1,3 @@
|
||||
/tool/wol mac=00:00:00:00:00:00 interface=bridge;
|
||||
/tool/wol mac=00:00:00:00:00:00 interface=ether4;
|
||||
|
13
text-file-to-json.rb
Executable file
13
text-file-to-json.rb
Executable file
@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require "json"
|
||||
|
||||
object = { "name" => "default", "source" => "" }
|
||||
|
||||
script_name = ARGV[0]
|
||||
filename = ARGV[1]
|
||||
|
||||
object["name"] = script_name
|
||||
object["source"] = File.open(filename).readlines.join("\r\n")
|
||||
|
||||
puts JSON.pretty_generate(object)
|
Loading…
Reference in New Issue
Block a user