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

29 lines
533 B
Bash
Raw Normal View History

2024-03-31 23:33:33 +03:00
#!/usr/bin/env bash
DEBUG="0"
ROUTEROS_HOST="$1"
USERNAME="$2"
PASSWORD="$3"
SCRIPT_NAME="$4"
SCRIPT_FILENAME="$5"
if [ ! -z "${SCRIPT_NAME}" ]
then
2024-03-31 23:36:10 +03:00
if [ ! -f "${SCRIPT_FILENAME}" ]
then
echo "The file [ \"${SCRIPT_FILENMAE}\" ] is missing" >&2
exit 1
fi
2024-03-31 23:33:33 +03:00
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