The idea to create an alarm clock based on Asterisk was a long time ago, because From the usual alarm clock, it did not always work out, unlike a call. The idea is as follows: on the website we ask your phone number and the time when you need to wake up (taking into account the days of the week). When the hour comes X and minute Y, Asterisk calls the specified number and plays the abusive record of the need for speedy recovery.

Asterisk supports automatic dialing by generating call-files.
The .call file is text files that, when placed in a specific directory (by default / var / spool / asterisk / outgoing /), force Asterisk to make an outgoing call.
Based on this function, an alarm clock with a web interface was implemented.
')
The whole software part of the alarm consists of 3 files:
index.php - web-based alarm interface, through which it is possible to view, add or delete alarms.
alarm.list is the file containing the current list of alarms in CSV format. The file structure is as follows:
telephone_number, mon_time, Tuesday_, midtime, mid_time, Fri_time, mid_time, all_time
Time format: hours: minutes.
Consider an example. Let's create an alarm clock on Monday 16:30 and Friday 18:40 for the number 81234567890.

The following entry will appear in the alarm.list file:
81234567890,16: 30 ,,,, 18:40 ,,
Asterisk will call this number every Monday at 16:30 and Friday at 18:40.
parsing.sh is a script that saves data from alarm.list and creates call-files for Asterisk. This file also contains the variables necessary for the formation of a call-file:
CALLPATH = '/ var / spool / asterisk / outgoing' # Directory of Asterisk call-files
CHANNEL = 'Dongle / dongle0' # Channel through which we will call
MAXRETRIES = '2' # Number of dialer attempts
RETRYTIME = '240' # Delay between attempts
WAITTIME = '30 '# Response timeout
DATA = '/ var / lib / asterisk / sounds / ru / wakeup' # Path to the played audio file
To run the script, you must pass it the path to alarm.list:
/var/www/alarm/parsing.sh /var/www/alarm/alarm.list
In response (if the DEBUG variable is uncommented), the script will display a list of active alarms.

This file must be added to cron on launching once a minute. An example entry in / etc / crontab:
#Alarm
* * * * * root /var/www/alarm/parsing.sh /var/www/alarm/alarm.list
Archive with all files can be downloaded
from the link .