#!/bin/bash # # Trivial script to control an Siemens S675/S685IP VoIP DECT base # # Usage: # # s675.bsh PUT # -> upload a .vcf phonebook file to the handset # # s675.bsh GET # -> download handset phonebook as .vcf file # # s675.bsh CLEAR # -> clear phonebook of given handset # # s675.bsh REBOOT # -> reboot base by toggling the G729 Annex B (silence surpression) switch # # Written by Oliver Wagner , Public Domain # # Notes: # - no other session may be active when running the script, otherwise, the login will fail. # - vcf files must have \r\n line endings and, for all current handsets, be UTF-8 encoded. # # Configuration: IP and PIN of the base station # S675IP=192.168.0.15 PIN=4711 # # Here be dragons # MODE=$1 PORT=$2 FILENAME=$3 if [ -z "$1" ]; then echo "Usage: $0 PUT PORT FILE | GET PORT FILE | CLEAR PORT | REBOOT" exit fi COOKIES=/tmp/s685cookie.dat function waitstatus { # Loop while status while true; do sleep 5 statusline=$(curl -c $COOKIES -b $COOKIES -sS http://$S675IP/status.html | tee /tmp/s675.laststatus | grep "var *status *= *") if [[ "$statusline" =~ var\ *status\ *=\ *([0-9]+) ]]; then status=${BASH_REMATCH[1]} if [ $status -gt 15 ]; then break fi fi done curl -c $COOKIES -b $COOKIES -sS http://$S675IP/stoptdt.html -o/dev/null } # First, login and get the key cookie curl -c $COOKIES -sS -d language=1 -d password=$PIN http://$S675IP/login.html -o/dev/null if [ "GET" = "$1" ]; then curl -c $COOKIES -b $COOKIES -sS -L -d tdt_function=1 -d tdt_handset_port=$PORT http://$S675IP/settings_telephony_tdt.html -o$FILENAME elif [ "CLEAR" = "$1" ]; then curl -c $COOKIES -b $COOKIES -sS -L -F tdt_function=3 -F tdt_handset_port=$PORT http://$S675IP/settings_telephony_tdt.html -o/dev/null waitstatus elif [ "PUT" = "$1" ]; then # Then upload curl -c $COOKIES -b $COOKIES -sS -L -F tdt_function=2 -F tdt_handset_port=$PORT -F tdt_file=@$FILENAME http://$S675IP/settings_telephony_tdt.html -o/dev/null waitstatus elif [ "REBOOT" = "$1" ] ; then isset=$(curl -c $COOKIES -b $COOKIES -sS -L http://$S675IP/settings_telephony_audio.html|grep "use_G729_B.*value=.0.*checked"|wc -l) # Blatantly toggle the G729 ANNEX-B switch (Silence surpression) curl -c $COOKIES -b $COOKIES -sS -L -d use_G729_B=$isset http://$S675IP/settings_telephony_audio.html -o/dev/null fi # Logout again, so others can log in curl -c $COOKIES -b $COOKIES -sS http://$S675IP/logout.html -o/dev/null