FREEPBX DEVICE AMPUSER


asterisk -rx “database show” | grep “AMPUSER” | grep “device” | awk ‘{print $1}’ | cut -d’/’ -f3,4 > AMPUSER

asterisk -rx “database show” | grep “DEVICE” | grep -w “user” | awk ‘{print $1}’ | cut -d’/’ -f3,4 > DEVICE

 

for i in `cat AMPUSER`; do
echo $i;
/usr/sbin/asterisk -rx “database del AMPUSER $i”
done
for i in `cat DEVICE`; do
echo $i;
/usr/sbin/asterisk -rx “database del DEVICE $i”
done

amportal restart

 

[macro-user-logon]
exten => s,1,Set(DEVICETYPE=${DB(DEVICE/${CALLERID(number)}/type)})
exten => s,n,Answer()
exten => s,n,Wait(1)
exten => s,n,GotoIf($[“${DEVICETYPE}” = “fixed”]?s-FIXED,1)
; get user’s extension
;
exten => s,n,Set(AMPUSER=${ARG1})
exten => s,n,GotoIf($[“${AMPUSER}” != “”]?gotpass)
exten => s,n(playagain),Read(AMPUSER,please-enter-your-extension-then-press-pound,,,4)
; get user’s password and authenticate
;
exten => s,n,GotoIf($[“${AMPUSER}” = “”]?s-MAXATTEMPTS,1)
exten => s,n(gotpass),GotoIf($[“${DB_EXISTS(AMPUSER/${AMPUSER}/password)}” = “0”]?s-NOUSER,1)
exten => s,n,Set(AMPUSERPASS=${DB_RESULT})
exten => s,n,GotoIf($[${LEN(${AMPUSERPASS})} = 0]?s-NOPASSWORD,1)
; do not continue if the user has already logged onto this device
;
exten => s,n,Set(DEVICEUSER=${DB(DEVICE/${CALLERID(number)}/user)})
exten => s,n,Noop(OVERRITEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE ===== = ${AMPUSER})
exten => s,n,GotoIf($[“${DEVICEUSER}” = “${AMPUSER}”]?s-ALREADYLOGGEDON,1)
;exten => s,n,AGI(check_user.sh,${AMPUSER})
;exten => s,n,GotoIf($[“${DEVICEUSER}” != “”]?s-ALREADY_LOGIN_FROM_EXTENSION,1)

exten => s,n,Set(IS_USED=${SHELL(/usr/sbin/asterisk -rx “database show” | grep ${AMPUSER} | grep /AMPUSER/${AMPUSER}/device | awk ‘{print $3}’)})
exten => s,n,GotoIf($[“${IS_USED}” != “”]?s-ALREADY_LOGIN_FROM_EXTENSION,1)

 

exten => s-ALREADY_LOGIN_FROM_EXTENSION,1,NoOp(This device has already ALREADY_LOGIN_FROM_EXTENSION)
exten => s-ALREADY_LOGIN_FROM_EXTENSION,n,Playback(already_logon_from)
exten => s-ALREADY_LOGIN_FROM_EXTENSION,n,Saydigits(${IS_USED})
exten => s-ALREADY_LOGIN_FROM_EXTENSION,n,Hangup ;TODO should play msg indicated device is already logged into

 

 

/AMPUSER/2036/device : 153
/DEVICE/153/user : 2036

database put AMPUSER 4002/password 1111
exten => s,n,Set(AMPUSER=${ARG1})
exten => s,n,Set(DEVICEUSER=${DB(DEVICE/${CALLERID(number)}/user)})
exten => s,n,GotoIf($[“${DEVICEUSER}” = “${AMPUSER}”]?s-ALREADYLOGGEDON,1)

exten => s,n,GotoIf($[“${DEVICEUSER}” != “”]?s-ALREADY_LOGIN_FROM_EXTENSION,1)
exten => s-ALREADY_LOGIN_FROM_EXTENSION,1,NoOp(This device has already ALREADY_LOGIN_FROM_EXTENSION)
exten => s-ALREADY_LOGIN_FROM_EXTENSION,n,Playback(vm-goodbye)
exten => s-ALREADY_LOGIN_FROM_EXTENSION,n,Hangup ;TODO should play msg indicated device is already logged into
asterisk -rx “database show” | grep 1006 | grep /AMPUSER/1006/device | awk ‘{print $3}’

asterisk -rx “database del AMPUSER 2036/device”

asterisk -rx “database del DEVICE 153/user”

agent-alreadyon.alaw

asterisk -rx “database show” | grep “AMPUSER” | grep “device” | awk ‘{print $1}’ | cut -d’/’ -f3,4 > AMPUSER

asterisk -rx “database show” | grep “DEVICE” | grep -w “user” | awk ‘{print $1}’ | cut -d’/’ -f3,4 > DEVICE

for i in `cat AMPUSER`; do
echo $i;
/usr/sbin/asterisk -rx “database del AMPUSER $i”
done
for i in `cat DEVICE`; do
echo $i;
/usr/sbin/asterisk -rx “database del DEVICE $i”
done

amportal restart

macro-user-logon
exten => s,n,AGI(check_user.sh,${DEVICEUSER})

from.alaw
vm-from-extension.ulaw
vm-from-phonenumber.gsm

#!/bin/bash
DEVICEUSER=$1
VAL=`/usr/sbin/asterisk -rx “database show” | grep ${DEVICEUSER} | grep /AMPUSER/${DEVICEUSER}/device | awk ‘{print $3}’`

if [ “$VAL” != ” ];then
echo “A
fi

exit 0

chmod +x /var/lib/asterisk/agi-bin/check_user.sh

exten => s,n,Set(result=${SHELL(/usr/sbin/asterisk -rx “database show” | grep 1006 | grep /AMPUSER/1006/device | awk ‘{print $3}’ | tr -d ‘\r’))
exten => s,n,Noop(HASIL ADALAH : ${result})


Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

shisdew

Listens until think alike

moses.spaceku@yahoo.com / voip ipbx

Hosted PBX, IP-PBX SOHO/ CALL CENTER, VOICE GATEWAY, VOICE CARD, COST EFECTIVE SOLUTIONS (LCR), GSM/CDMA GATEWAY

%d bloggers like this: