updated to just use email instead of phone. updated log file variables

This commit is contained in:
2022-05-20 18:14:13 -04:00
parent f9e5af96ca
commit 0c72917c87

View File

@@ -1,16 +1,16 @@
#!/bin/bash
URL=${1}
PHONE_NUMBER=${2}
EMAIL=${2}
NAME=${3}
LOG_FILE="/tmp/Ubiquiti Stock ${NAME}.log"
echo "" > "${LOG_FILE}"
echo "URL: ${1}" | tee -a "${LOG_FILE}"
echo "Phone Number: ${2}" | tee -a "${LOG_FILE}"
echo "Name: ${3}" | tee -a "${LOG_FILE}"
echo "URL: ${URL}" | tee -a "${LOG_FILE}"
echo "Email: ${Email}" | tee -a "${LOG_FILE}"
echo "Name: ${Name}" | tee -a "${LOG_FILE}"
SOURCE_FILE="/tmp/Ubiquiti Stock ${NAME}.source"
@@ -25,7 +25,7 @@ echo "Inventory Quantity: ${INVENTORY_QUANTITY}" | tee -a "${LOG_FILE}"
if [[ "${INVENTORY_QUANTITY}" -gt "0" ]]; then
MESSAGE="There are currently ${INVENTORY_QUANTITY} ${NAME} in stock. ${URL}"
echo "Message: ${MESSAGE}" | tee -a "${LOG_FILE}"
echo "${MESSAGE}" | mailx -r "stockalerts@johnhgaunt.com" --set smtp="smtp.home.johnhgaunt.com:25" ${PHONE_NUMBER}@vtext.com
echo "${MESSAGE}" | mailx -r "stockalerts@johnhgaunt.com" --set smtp="smtp.home.johnhgaunt.com:25" ${Email}
echo "Email sent" | tee -a "${LOG_FILE}"
else
echo "Not sending email" | tee -a "${LOG_FILE}"