routeros-add-script/add-system-script.sh

28 lines
436 B
Bash
Raw Normal View History

2024-03-31 23:33:33 +03:00
#!/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