function pjsipsetup
{
shift
export ip=$1
if [ -z $ip ];then
echo enter ip
read ip
fi
cat >> pjsip.conf<<EOF
[transport-tcp]
type=transport
protocol=tcp
bind=$ip
EOF
}
function pjsipadduser
{
shift
export user=$1
export pass=$2
if [ -z $user ];then
echo enter user to add
read user
fi
if [ -z $pass ];then
echo enter password for $user
read pass
fi
cat >> pjsip.conf<<EOF
[$user]
type=endpoint
context=from-internal
disallow=all
allow=ulaw
auth=$user
aors=$user
[$user]
type=auth
auth_type=userpass
password=$pass
username=$user
[$user]
type=aor
max_contacts=65536
EOF
cat >> extensions.conf<<EOF
exten => $user,1,Dial(PJSIP/$user)
EOF
}
function newsndext
{
shift
export ext=$1
export sound=$2
if [ -z $ext ];then
echo enter extension to add
read ext
fi
if [ -z $sound ];then
echo enter sound for extension
read sound
fi
cat >> extensions.conf<<EOF
[from-internal]
exten = $ext,1,Answer()
same = n,Wait(1)
same = n,Playback($sound)
same = n,Hangup()
EOF
}
case "$1" in
"setup")
pjsipsetup $@
;;
adduser)
pjsipadduser $@
;;
newsndext)
newsndext $@
;;
esac
