Wake Up Function

Discussion in 'General' started by danardf, May 2, 2009.

  1. danardf

    Joined:
    Dec 3, 2007
    Messages:
    8,069
    Likes Received:
    12
    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.
     
  2. gamba47

    Joined:
    May 28, 2009
    Messages:
    595
    Likes Received:
    0
    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
     
  3. danardf

    Joined:
    Dec 3, 2007
    Messages:
    8,069
    Likes Received:
    12
    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:
     
  4. Patrick_elx

    Joined:
    Dec 14, 2008
    Messages:
    1,120
    Likes Received:
    0
  5. danardf

    Joined:
    Dec 3, 2007
    Messages:
    8,069
    Likes Received:
    12
    It's very interesting.

    Thanks for this link Patrick ;)
     
  6. gamba47

    Joined:
    May 28, 2009
    Messages:
    595
    Likes Received:
    0
    Thanks Patrick!


    gamba47
     
  7. rafael

    Joined:
    May 14, 2007
    Messages:
    1,454
    Likes Received:
    1
    @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
     
  8. danardf

    Joined:
    Dec 3, 2007
    Messages:
    8,069
    Likes Received:
    12
    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!
     
  9. dicko

    Joined:
    Oct 24, 2008
    Messages:
    4,099
    Likes Received:
    0
    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
     
  10. rafael

    Joined:
    May 14, 2007
    Messages:
    1,454
    Likes Received:
    1
    I think you are right dico ;)
     

Share This Page