2022-01-09 12:50:54 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# only for Russia!!!
|
|
|
|
COUNTRY_CODE="7"
|
|
|
|
|
|
|
|
USER="smsd"
|
|
|
|
GROUP="smsd"
|
2022-01-10 09:13:54 +00:00
|
|
|
SPOOLDIR="/srv/data/sms/outgoing/"
|
2022-01-09 12:50:54 +00:00
|
|
|
|
|
|
|
if [ -z "$*" ]; then
|
|
|
|
echo "Usage: ./sendsms.sh \"phone number\" \"message\""
|
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
|
|
|
|
DST=$1
|
|
|
|
MSG=$2
|
|
|
|
|
|
|
|
if [[ -z "${DST}" ]]; then
|
|
|
|
echo "No destination phone number"
|
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -z "${MSG}" ]]; then
|
|
|
|
echo "No message"
|
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $DST == +* ]]; then
|
|
|
|
DST=${DST:1:11}
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ${#DST} == 10 ]]; then
|
|
|
|
DST="$COUNTRY_CODE$DST"
|
|
|
|
elif [[ ${#DST} == 11 && $DST == 8* ]]; then
|
|
|
|
DST="$COUNTRY_CODE${DST:1:10}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ${#DST} != 11 ]]; then
|
|
|
|
echo "Error in destination phone number"
|
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
|
|
|
|
SMS=$(mktemp /tmp/sms_XXXXXXX)
|
|
|
|
chown :${GROUP} ${SMS}
|
|
|
|
chmod 0666 ${SMS}
|
|
|
|
|
|
|
|
echo "To: ${DST}" >> $SMS
|
|
|
|
echo "" >> $SMS
|
|
|
|
echo $MSG >> $SMS
|
|
|
|
|
|
|
|
mv ${SMS} ${SPOOLDIR}
|
|
|
|
|
|
|
|
echo 1
|
|
|
|
exit 1
|