routeros-add-script/add-system-script.sh
Eliezer Croitoru 09ebb5c0f4 2
2024-03-31 23:36:10 +03:00

29 lines
533 B
Bash
Executable File

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