Wake Up Function

danardf

Joined
Dec 3, 2007
Messages
8,069
Likes
10
Points
88
#1
Hi every body.

I did make a little Wake Up function.
Simple.

Show the following procedure:

Create a shell script like wakeup into /bin for exemple.

wapeup file:
Code:
rm -f /var/spool/asterisk/tmp/wakeup-*
rm -f /var/spool/asterisk/outgoing/wakeup-*
wakeup=`date +%m%d`
echo "Channel: Local/$2@from-internal" >> /var/spool/asterisk/tmp/wakeup-$1-$2
echo "CallerID: wakeup <$2>" >> /var/spool/asterisk/tmp/wakeup-$1-$2
echo "MaxRetries: 2" >> /var/spool/asterisk/tmp/wakeup-$1-$2
echo "RetryTime: 60" >> /var/spool/asterisk/tmp/wakeup-$1-$2
echo "WaitTime: 30" >> /var/spool/asterisk/tmp/wakeup-$1-$2
echo "Context: calendar-event" >> /var/spool/asterisk/tmp/wakeup-$1-$2
echo "Extension: *7899" >> /var/spool/asterisk/tmp/wakeup-$1-$2
echo "Priority: 1" >> /var/spool/asterisk/tmp/wakeup-$1-$2
echo "Set: FILE_CALL=custom/$2/wakeup.gsm" >> /var/spool/asterisk/tmp/wakeup-$1-
$2
echo "Set: ID_EVENT_CALL=3" >> /var/spool/asterisk/tmp/wakeup-$1-$2
/bin/touch -t $wakeup$1 /var/spool/asterisk/tmp/wakeup-$1-$2
mv /var/spool/asterisk/tmp/wakeup-$1-$2 /var/spool/asterisk/outgoing/
chgrp asterisk /var/spool/asterisk/outgoing/wakeup-$1-$2
chown asterisk /var/spool/asterisk/outgoing/wakeup-$1-$2
For starting, I begin to delete all old files wakeup*
Next, I create the config file.
Next, I change the time's file.
Next, I move the file into outgoing directory.
For ending, I change the asterisk (group and own).

Into extensions_custormer.conf, I add this:

Code:
[wakeup]
exten => s,1,Answer()
exten => s,n,playback(wakeup-call)
exten => s,n,Wait(1)
exten => s,n(start),playback(press-1)
exten => s,n,playback(for-a-daily-wakeup-call)
exten => s,n,playback(press-2)
exten => s,n,playback(to-cancel-wakeup)
exten => s,n,playback(press-star-cancel)
exten => s,n,Read(choice,,1)
exten => s,n,GotoIf($["${choice}" = "1"]?wakeup)
exten => s,n,GotoIf($["${choice}" = "2"]?Delete)
exten => s,n,GotoIf($["${choice}" = "*"]?End)
exten => s,n,playback(bad)
exten => s,n,playback(service)
exten => s,n,Gosub(start)
exten => s,n(wakeup),playback(wakeup-for-one-time)
exten => s,n,playback(enter-a-time)
exten => s,n,Read(hour,,4)
exten => s,n,SayDigits(${heure})
exten => s,n,playback(you-entered) 
exten => s,n,SayDigits(${hour})
exten => s,n,system(/bin/wakeup ${hour} ${CALLERID(num)})
exten => s,n,playback(hours)
exten => s,n,playback(recorded)
exten => s,n,Gosub(End)
exten => s,n(Delete),system(/bin/rm -f /var/spool/asterisk/outgoing/wakeup*)
exten => s,n,playback(wakeup-call-cancelled)
exten => s,n,Gosub(End)
exten => s,n(End),playback(thank-you-for-calling)
exten => s,n,Hangup()
And, to ending, I affect into custom destination, this function: wakeup,s,1, and affect a code for this function (60 for exemple)

Like this, if I call the 60, I must put the hour with this format (4 digits).
My code is for 24h format, you can modify this code for 12H format.
 

gamba47

Joined
May 28, 2009
Messages
595
Likes
0
Points
0
#2
danardf, this function is already in Elastix 1.5 ?

I read extension_custom.conf and have an option called wakeup with number 62.

Thanks for the tip!

gamba47
 

danardf

Joined
Dec 3, 2007
Messages
8,069
Likes
10
Points
88
#3
HMmmmm.. It's strange because at home, I haven't this custom extension!
Maybe it's because I did make a fresh install and a restore after. ... Why not.

thank's for this information :laugh:
 

Patrick_elx

Joined
Dec 14, 2008
Messages
1,120
Likes
0
Points
0
#4

danardf

Joined
Dec 3, 2007
Messages
8,069
Likes
10
Points
88
#5
It's very interesting.

Thanks for this link Patrick ;)
 

gamba47

Joined
May 28, 2009
Messages
595
Likes
0
Points
0
#6
Thanks Patrick!


gamba47
 

rafael

Joined
May 14, 2007
Messages
1,454
Likes
1
Points
0
#7
@danardf, just a note

The scripts you create should be created under /usr/local/bin (normal privileges) or /usr/local/sbin (root privileges).

Best regards,

RAfael
 

danardf

Joined
Dec 3, 2007
Messages
8,069
Likes
10
Points
88
#8
Hi Rafa.

This script must be create with chmod 777 into /bin/wakeup

If you look this link:
exten => s,n,system(/bin/wakeup ${hour} ${CALLERID(num)})

But you can put this script where you want, if you change the directory into the extension_custom. ;)

But you are right. Norlamlly, I must put the script into these directory and not /bin. but why not!
 

dicko

Joined
Oct 24, 2008
Messages
4,099
Likes
0
Points
0
#9
Hey guys!

Well surely the asterisk user's home directory is /var/lib/asterisk, so logically any executable in /var/lib/asterisk/bin with a mode of 7xx would be both usable by asterisk and less vulnerable to abuse (easy to backup, and easier to find next year).

thus for explicitness

. . . .This script must be create with chmod 777 into /bin/wakeup

is maybe better:

. . . .This script must be create with chmod 700 into /var/lib/asterisk/bin/wakeup
(some might argue for ../sbin , I'm not that much of a purist however)

Just my 2centimes(centavos) worth.

regards dicko
 

rafael

Joined
May 14, 2007
Messages
1,454
Likes
1
Points
0
#10
I think you are right dico ;)
 

Members online

No members online now.

Latest posts

Forum statistics

Threads
30,915
Messages
130,920
Members
17,595
Latest member
feparra121
Top