sipwise-reminder package created

trunk@3605
Jon Bonilla 16 years ago
commit 4db94b6ff0

5
debian/changelog vendored

@ -0,0 +1,5 @@
sipwise-reminder (0.1.0-1) unstable; urgency=low
* Initial release.
-- Jon Bonilla <jbonilla@sipwise.com> Fri, 16 Apr 2010 12:03:01 +0200

1
debian/compat vendored

@ -0,0 +1 @@
5

13
debian/control vendored

@ -0,0 +1,13 @@
Source: sipwise-reminder
Section: comm
Priority: extra
Maintainer: Jon Bonilla <jbonilla@sipwise.com>
Build-Depends: debhelper (>= 5)
Standards-Version: 3.8.4
Homepage: http://sipwise.com/
Package: sipwise-reminder
Architecture: all
Depends: ${shlibs:Depends}, ${misc:Depends}, perl-modules, libdbi-perl, sipwise-asterisk
Description: Reminder call scripts
Scripts for Sipwise reminder calls.

7
debian/copyright vendored

@ -0,0 +1,7 @@
Upstream Author: The Sipwise Team - http://sipwise.com/
Copyright: Copyright (c) 2007-2010 Sipwise GmbH, Austria
License: All software included in this package is
Copyright (c) Sipwise GmbH, Austria.
All rights reserved. You may not copy, distribute
or modify without prior written permission from
Sipwise GmbH, Austria.

62
debian/rules vendored

@ -0,0 +1,62 @@
#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
build: build-stamp
build-stamp:
dh_testdir
#cd docs && make && cd ..
touch $@
clean:
dh_testdir
dh_testroot
rm -f build-stamp
#cd docs && make clean && cd ..
dh_clean
install: build
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs usr/sbin /etc/cron.d /etc/sipwise-reminder
install -m 755 reminder.pl debian/sipwise-reminder/usr/sbin/reminder
install -m 644 reminder.cron debian/sipwise-reminder/etc/cron.d/reminder
install -m 644 reminder.conf debian/sipwise-reminder/etc/sipwise-reminder/reminder.conf
# Build architecture-dependent files here.
binary-arch: build install
# We have nothing to do by default.
# Build architecture-independent files here.
binary-indep: build install
dh_testdir
dh_testroot
dh_installchangelogs
dh_installdocs
dh_installexamples
#dh_installman docs/rate-o-mat.8
dh_installinit
dh_link
dh_strip
#mkdir -p $(CURDIR)/debian/sipwise-rate-o-mat/usr/share/lintian/overrides/
#cp -av debian/overrides $(CURDIR)/debian/sipwise-rate-o-mat/usr/share/lintian/overrides/sipwise-rate-o-mat
dh_compress
dh_fixperms
dh_installdeb
dh_shlibdeps
dh_gencontrol
dh_md5sums
dh_builddeb
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install

@ -0,0 +1,16 @@
#Configuration file for sipwise-reminder call scripts
#callfile settings
retries = 2
retry_time = 60
wait_time = 30
context = reminder
sip_peer = sip_proxy
spool = /var/spool/asterisk/outgoing
tmpdir = /tmp
#database settings
database = provisioning
dbhost = localhost
dbuser= soap
dbpassword = s:wMP4Si

@ -0,0 +1 @@
* * * * * root /usr/sbin/reminder 1>/dev/null

@ -0,0 +1,87 @@
#!/usr/bin/perl -w
use strict;
use File::Temp qw(tempfile);
use File::Basename;
use File::Copy;
use DBI;
our $retries;
our $retry_time;
our $wait_time;
our $context;
our $sip_peer;
our $spool;
our $tmpdir;
our $database;
our $dbhost;
our $dbuser;
our $dbpassword;
my $config_file = "/etc/sipwise-reminder/reminder.conf";
open CONFIG, "$config_file" or die "Program stopping, couldn't open the configuration file '$config_file'.\n";
while (<CONFIG>) {
chomp; # no newline
s/#.*//; # no comments
s/^\s+//; # no leading white
s/\s+$//; # no trailing white
next unless length; # anything left?
my ($var, $value) = split(/\s*=\s*/, $_, 2);
no strict 'refs';
$$var = $value;
}
close CONFIG;
my $dsn = "DBI:mysql:database=$database;host=$dbhost;port=0";
my $dbh = DBI->connect($dsn, $dbuser, $dbpassword);
my $sth = $dbh->prepare("SELECT a.username, b.domain, c.recur, c.id " .
"FROM voip_subscribers a, voip_domains b, voip_reminder c " .
"WHERE c.subscriber_id = a.id and a.domain_id = b.id " .
"and c.time = time_format(now(), '%H:%i:00')");
my $sth_d = $dbh->prepare("delete from voip_reminder where id=?");
$sth->execute;
while (my $ref = $sth->fetchrow_hashref())
{
print "$ref->{'username'}\@$ref->{'domain'}, recur=$ref->{'recur'}\n";
if($ref->{'recur'} eq "weekdays")
{
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time);
next if($wday == 0) # only exclude sunday for now
}
my ($tmp, $tmp_filename) = tempfile("$ref->{'username'}.XXXXXX", DIR => $tmpdir, UNLINK => 0);
unless(defined $tmp)
{
die "Failed to create temporary call file: $!\n";
}
print "Using tmpfile '$tmp_filename'\n";
print $tmp "Channel: SIP/$sip_peer/$ref->{'username'}\n";
print $tmp "MaxRetries: $retries\n";
print $tmp "RetryTime: $retry_time\n";
print $tmp "WaitTime: $wait_time\n";
print $tmp "Extension: s\n";
print $tmp "Context: $context\n";
print $tmp "Priority: 1\n";
close $tmp;
move "$tmp_filename", "$spool/".basename($tmp_filename)
or die "Failed to move call '$tmp_filename' file to spool: $!\n";
if($ref->{'recur'} eq "never")
{
$sth_d->execute($ref->{'id'});
}
}
$sth->finish;
Loading…
Cancel
Save