-
-
Save zackfuchtel/4d9fc31991ffb60f297e2d89a17ee3e3 to your computer and use it in GitHub Desktop.
Sending a SMS from a mikrotik LTE device reset API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| ALLOWED_NUMBERS_FILE="destinations.txt" | |
| MOBILE_NUMBER="$1" | |
| DRY_RUN="0" | |
| if [ -f "dry-run" ];then | |
| DRY_RUN="1" | |
| echo "### RUNNING IN DRY RUN MODE ###" | |
| echo | |
| echo | |
| fi | |
| if [ -z "${MOBILE_NUMBER}" ];then | |
| echo "Missing mobile number" | |
| exit 1 | |
| fi | |
| grep "${MOBILE_NUMBER}" "${ALLOWED_NUMBERS_FILE}" >/dev/null | |
| if [ "$?" -gt "0" ];then | |
| echo "This mobile number: \"${MOBILE_NUMBER}\" is not allowed" | |
| exit 3 | |
| fi | |
| MSG="$2" | |
| if [ -z "${MSG}" ];then | |
| echo "Missing message text to send in the sms" | |
| exit 2 | |
| fi | |
| USER="admin" | |
| PASSWORD="1234" | |
| LTE_ROUTER_ADDRESS="192.168.88.1" | |
| URL="https://${LTE_ROUTER_ADDRESS}/rest/tool/sms/send" | |
| echo "Sending sms to: \"${MOBILE_NUMBER}\" via URL: \"${URL}\"" | |
| echo "Message: \"${MSG}\"" | |
| JSON_DATA="{\"port\" : \"lte1\", \"message\" : \"${MSG}\", \"phone-number\" : \"${MOBILE_NUMBER}\"}" | |
| if [ "${DRY_RUN}" -eq "0" ];then | |
| curl -k -u ${USER}:${PASSWORD} ${URL} \ | |
| -H "Content-Type: application/json" \ | |
| --data "${JSON_DATA}" | |
| else | |
| echo | |
| echo "DRY RUN, should send the next JSON to the LTE Router" | |
| echo | |
| echo "${JSON_DATA}" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment