Académique Documents
Professionnel Documents
Culture Documents
/bin/bash
########################################
SIP_HOST='192.168.123.151'
SIP_USER='test'
SIP_PASS='test'
CALL='10'
TEXT2WAVE='/usr/bin/text2wave'
TMPDIR='/usr/local/icinga/etc/objects'
########################################
get_phone_state () {
linphonecsh status register 2>/dev/null 1>&2
if [ $? -eq $1 ]; then
true
else
false
fi
}
get_call_state () {
linphonecsh status hook 2>/dev/null 1>&2
if [ $? -eq $1 ]; then
true
else
false
fi
}
function usage(){
echo "usage: $0 -r -m \"<message>\""
exit 1
}
if [ $# -lt 2 ]; then
usage
fi
while getopts "r:m:" OPTION; do
case $OPTION in
r)
RECIPIENT="sip:$OPTARG@$SIPREALM"
;;
m)
MESSAGE="$OPTARG"
;;
*)
usage
;;
esac
done
#Check
if [ ! -x "$TEXT2WAVE" ]; then
echo "$TEXT2WAVE not found!"
exit 1
fi
if [ "$RECIPIENT" = "" ]; then
usage
fi
if [ "$MESSAGE" = "" ]; then
usage
fi
# Create Date
DATE=`date +%y%m%d%k%M|sed 's/ /0/'`
# generate message
MSGWAV=$TMPDIR/$DATE.$RANDOM.wav
$TEXT2WAVE -o $MSGWAV -f 8000 << EOF
$MESSAGE
EOF
# ret code 255 = no daemon started
if get_phone_state 255; then
echo "Starting Phone client ..."
linphonecsh init
while get_phone_state 255; do sleep 0.2; done
else echo "Phone client already started ..."
fi