Skip to content
Snippets Groups Projects
Commit f582495d authored by Mark Spencer's avatar Mark Spencer
Browse files

Move scripts to contrib/scripts

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1963 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent 071ea96f
Branches
Tags
No related merge requests found
......@@ -401,7 +401,7 @@ webvmail:
@[ -d $(DESTDIR)$(HTTPDIR) ] || ( echo "No HTTP directory" && exit 1 )
@[ -d $(DESTDIR)$(HTTPDIR)/html ] || ( echo "No http directory" && exit 1 )
@[ -d $(DESTDIR)$(HTTPDIR)/cgi-bin ] || ( echo "No cgi-bin directory" && exit 1 )
install -m 4755 -o root -g root vmail.cgi $(DESTDIR)$(HTTPDIR)/cgi-bin/vmail.cgi
install -m 4755 -o root -g root contrib/scripts/vmail.cgi $(DESTDIR)$(HTTPDIR)/cgi-bin/vmail.cgi
mkdir -p $(DESTDIR)$(HTTPDIR)/html/_asterisk
for x in images/*.gif; do \
install -m 644 $$x $(DESTDIR)$(HTTPDIR)/html/_asterisk/; \
......@@ -416,7 +416,7 @@ webvmail:
@echo " +-------------------------------------------+"
mailbox:
./addmailbox
./contrib/scripts/addmailbox
rpm: __rpm
......
expire-messages.pl
expire-messages finds messages more than X days old and deletes them.
Because the older messages will be the lower numbers in the folder (msg0000
will be older than msg0005), just deleting msg0000 will not work.
expire-messages then runs a routine that goes into every folder in every
mailbox to reorganize. If the folder contains msg0000, no action is taken.
If the folder does not, the rename routine takes the oldest message and
names it msg0000, the next oldest message and names it msg0001 and so on.
The file deletion is done by the -exec parameter to 'find'. It would be far
more efficient to take the output from 'find' and just reorganize the
directories from which we deleted a file. Something for the future...
Keep in mind that messages are deleted at the beginning of the script you
will have mailbox trouble if you check messages before the script
reorganizes your mailbox.
To use it, make sure the paths are right. Adjust $age (originally set to
31) if necessary.
#!/bin/sh
clear
VMHOME=/var/spool/asterisk/voicemail
SNDHOME=/var/lib/asterisk/sounds
echo
echo "Enter Voicemail Context of the mailbox you are creating."
echo "The context is the value between the square brackets in"
echo "the voicemail.conf file."
echo "(DEFAULT: default)"
echo -n "Voicemail Context: "
read context
echo
echo "Enter the Mailbox number of the voicemail box you are creating."
echo -n "Mailbox Number: "
read mailbox
context=${context:-default}
if [ ! -e "${VMHOME}/${context}" ]
then
echo
echo "New Voicemail context.."
echo "Creating Voicemail context directory..."
mkdir -p ${VMHOME}/${context}
fi
echo
echo "Creating Voicemail directory..."
mkdir -p ${VMHOME}/${context}/${mailbox}
echo "Creating INBOX..."
mkdir -p ${VMHOME}/${context}/${mailbox}/INBOX
echo "Creating Default greetings..."
cat ${SNDHOME}/vm-theperson.gsm > ${VMHOME}/${context}/${mailbox}/unavail.gsm
cat ${SNDHOME}/vm-theperson.gsm > ${VMHOME}/${context}/${mailbox}/busy.gsm
cat ${SNDHOME}/vm-extension.gsm > ${VMHOME}/${context}/${mailbox}/greet.gsm
nums=`echo $mailbox | sed 's/./ \0/g'`
for x in $nums; do
cat ${SNDHOME}/digits/${x}.gsm >> ${VMHOME}/${context}/${mailbox}/unavail.gsm
cat ${SNDHOME}/digits/${x}.gsm >> ${VMHOME}/${context}/${mailbox}/busy.gsm
cat ${SNDHOME}/digits/${x}.gsm >> ${VMHOME}/${context}/${mailbox}/greet.gsm
done
cat ${SNDHOME}/vm-isunavail.gsm >> ${VMHOME}/${context}/${mailbox}/unavail.gsm
cat ${SNDHOME}/vm-isonphone.gsm >> ${VMHOME}/${context}/${mailbox}/busy.gsm
echo "Complete."
#!/usr/bin/perl
#
# Script to expire voicemail after a specified number of days
# by Steve Creel <screel@turbs.com>
#
# Directory housing the voicemail spool for asterisk
$dir = "/var/spool/asterisk/voicemail";
# Context for which the script should be running
$context = "default";
# Age (Delete files older than $age days old)
$age = 31;
# Delete all files older than $age (but named msg????.??? to be sure
# we don't delete greetings or the user's name)
system('find '.$dir.'/'.$context.' -name msg????.??? -mtime +'.$age.' -exec rm {} \; -exec echo Deleted {} \;');
# For testing - what number to we start when we renumber?
$start = "0";
# Rename to msg and a 4 digit number, 0 padded.
$fnbase = sprintf "msg%04d", $start;
# Make $dir include the context too
$dir.="/".$context;
( -d $dir ) || die "Can't read list of mailboxes ($dir): $!\n";
@mailboxes = `ls -A1 $dir`;
chomp(@mailboxes);
$save_fnbase = $fnbase;
foreach $mailbox (@mailboxes) {
( -d $dir."/".$mailbox) || die "Can't read list of folders (".$dir."/".$mailbox."): $!\n";
@folders = `ls -A1 $dir/$mailbox`;
chomp(@folders);
foreach $folder (@folders) {
if (-d $dir."/".$mailbox."/".$folder) {
( -d $dir."/".$mailbox."/".$folder) || die "Can't read list of messages (".$dir."/".$mailbox."/".$folder.") $!\n";
@files = `ls -A1 $dir/$mailbox/$folder/`;
# Sort so everything is in proper order.
@files = sort @files;
chomp(@files);
# If there is still (after deleting old files earlier in the
# script) a msg0000.txt, we don't need to shuffle anything
# in this folder.
if (-f $dir."/".$mailbox."/".$folder."/msg0000.txt") { next; }
foreach $ext (("WAV", "wav", "gsm", "txt")) {
# Reset the fnbase for each file type
$fnbase = $save_fnbase;
foreach $file (@files) {
if ( $file =~ /$ext/ ) {
chdir($dir."/".$mailbox."/".$folder."/") || die "Can't change folder: $!";
print "Renaming: ".$dir."/".$mailbox."/".$folder."/".$file." to ".$fnbase.".".$ext."\n";
rename($file, $fnbase.".".$ext) || die "Cannot rename: $!";
$fnbase++;
}
}
}
}
}
}
__END__
\ No newline at end of file
/*
* Id: postgres_cdr.sql,v 1.8.2.11 2003/10/10 11:15:43 pnixon Exp $
*
* --- Peter Nixon [ codemonkey@peternixon.net ]
*
* This is a PostgreSQL schema for doing CDR accounting with Asterisk
*
* The calls will automatically be logged as long as the module is loaded.
*
*/
CREATE TABLE cdr (
AcctId BIGSERIAL PRIMARY KEY,
calldate TIMESTAMP with time zone NOT NULL DEFAULT now(),
clid VARCHAR(80) NOT NULL default '',
src VARCHAR(80) NOT NULL default '',
dst VARCHAR(80) NOT NULL default '',
dcontext VARCHAR(80) NOT NULL default '',
channel VARCHAR(80) NOT NULL default '',
dstchannel VARCHAR(80) NOT NULL default '',
lastapp VARCHAR(80) NOT NULL default '',
lastdata VARCHAR(80) NOT NULL default '',
duration INTEGER NOT NULL default '0',
billsec INTEGER NOT NULL default '0',
disposition VARCHAR(45) NOT NULL default '',
amaflags INTEGER NOT NULL default '0',
accountcode VARCHAR(20) NOT NULL default '',
uniqueid VARCHAR(32) NOT NULL default ''
);
#!/usr/bin/perl -Tw
# Use these commands to create the appropriate tables in MySQL
# If flags is 1 then this record is not included in the output extensions file
#
#CREATE TABLE extensions (
# context CHAR(20) DEFAULT 'default' NOT NULL,
# extension CHAR(20) NOT NULL,
# priority INT(2) DEFAULT '1' NOT NULL,
# application CHAR(20) NOT NULL,
# args CHAR(50),
# descr TEXT,
# flags INT(1) DEFAULT '0' NOT NULL,
# PRIMARY KEY(context, extension, priority)
#);
#
#CREATE TABLE globals (
# variable CHAR(20) NOT NULL,
# value CHAR(50) NOT NULL,
# PRIMARY KEY(variable, value)
#);
use DBI;
################### BEGIN OF CONFIGURATION ####################
# the name of the extensions table
$table_name = "extensions";
# the name of the globals table
$global_table_name = "globals";
# the path to the extensions.conf file
# WARNING: this file will be substituted by the output of this program
$extensions_conf = "/etc/asterisk/extensions.conf";
# the name of the box the MySQL database is running on
$hostname = "localhost";
# the name of the database our tables are kept
$database = "user";
# username to connect to the database
$username = "";
# password to connect to the database
$password = "";
################### END OF CONFIGURATION #######################
open EXTEN, ">$extensions_conf" || die "Cannot create/overwrite extensions file: $extensions_conf\n";
$dbh = DBI->connect("dbi:mysql:dbname=$database;host=$hostname", "$username", "$password");
$statement = "SELECT * from $global_table_name order by variable";
my $result = $dbh->selectall_arrayref($statement);
unless ($result) {
# check for errors after every single database call
print "dbh->selectall_arrayref($statement) failed!\n";
print "DBI::err=[$DBI::err]\n";
print "DBI::errstr=[$DBI::errstr]\n";
exit;
}
my @resultSet = @{$result};
if ( $#resultSet > -1 ) {
print EXTEN "[globals]\n";
foreach $row (@{ $result }) {
my @result = @{ $row };
print EXTEN "$result[0] = $result[1]\n";
}
print EXTEN "\n";
}
$statement = "SELECT context from $table_name group by context";
$result = $dbh->selectall_arrayref($statement);
unless ($result) {
# check for errors after every single database call
print "dbh->selectall_arrayref($statement) failed!\n";
print "DBI::err=[$DBI::err]\n";
print "DBI::errstr=[$DBI::errstr]\n";
}
@resultSet = @{$result};
if ( $#resultSet == -1 ) {
print "No extensions defined in $table_name\n";
exit;
}
foreach my $row ( @{ $result } ) {
my $context = @{ $row }[0];
print EXTEN "[$context]\n";
$statement = "SELECT * from $table_name where context='$context' order by extension, priority";
my $result = $dbh->selectall_arrayref($statement);
unless ($result) {
# check for errors after every single database call
print "dbh->selectall_arrayref($statement) failed!\n";
print "DBI::err=[$DBI::err]\n";
print "DBI::errstr=[$DBI::errstr]\n";
exit;
}
my @resSet = @{$result};
if ( $#resSet == -1 ) {
print "no results\n";
exit;
}
foreach my $row ( @{ $result } ) {
my @result = @{ $row };
if ($result[6] == 0) {
print EXTEN "exten => $result[1],$result[2],$result[3]";
print EXTEN "($result[4])" if defined $result[4];
print EXTEN "\t" if not defined $result[4];
print EXTEN "\t; $result[5]" if defined $result[5];
print EXTEN "\n";
}
}
print EXTEN "\n";
}
exit 0;
#!/usr/bin/perl -Tw
# Retrieves the sip user/peer entries from the database
# Use these commands to create the appropriate tables in MySQL
#
#CREATE TABLE sip (id INT(11) DEFAULT -1 NOT NULL,keyword VARCHAR(20) NOT NULL,data VARCHAR(50) NOT NULL, flags INT(1) DEFAULT 0 NOT NULL,PRIMARY KEY (id,keyword));
#
# if flags = 1 then the records are not included in the output file
use DBI;
################### BEGIN OF CONFIGURATION ####################
# the name of the extensions table
$table_name = "sip";
# the path to the extensions.conf file
# WARNING: this file will be substituted by the output of this program
$sip_conf = "/etc/asterisk/sip_additional.conf";
# the name of the box the MySQL database is running on
$hostname = "localhost";
# the name of the database our tables are kept
$database = "sip";
# username to connect to the database
$username = "root";
# password to connect to the database
$password = "";
################### END OF CONFIGURATION #######################
$additional = "";
open EXTEN, ">$sip_conf" || die "Cannot create/overwrite extensions file: $sip_conf\n";
$dbh = DBI->connect("dbi:mysql:dbname=$database;host=$hostname", "$username", "$password");
$statement = "SELECT keyword,data from $table_name where id=0 and keyword <> 'account' and flags <> 1";
my $result = $dbh->selectall_arrayref($statement);
unless ($result) {
# check for errors after every single database call
print "dbh->selectall_arrayref($statement) failed!\n";
print "DBI::err=[$DBI::err]\n";
print "DBI::errstr=[$DBI::errstr]\n";
exit;
}
my @resultSet = @{$result};
if ( $#resultSet > -1 ) {
foreach $row (@{ $result }) {
my @result = @{ $row };
$additional .= $result[0]."=".$result[1]."\n";
}
}
$statement = "SELECT data,id from $table_name where keyword='account' and flags <> 1 group by data";
$result = $dbh->selectall_arrayref($statement);
unless ($result) {
# check for errors after every single database call
print "dbh->selectall_arrayref($statement) failed!\n";
print "DBI::err=[$DBI::err]\n";
print "DBI::errstr=[$DBI::errstr]\n";
}
@resultSet = @{$result};
if ( $#resultSet == -1 ) {
print "No sip accounts defined in $table_name\n";
exit;
}
foreach my $row ( @{ $result } ) {
my $account = @{ $row }[0];
my $id = @{ $row }[1];
print EXTEN "[$account]\n";
$statement = "SELECT keyword,data from $table_name where id=$id and keyword <> 'account' and flags <> 1 order by keyword";
my $result = $dbh->selectall_arrayref($statement);
unless ($result) {
# check for errors after every single database call
print "dbh->selectall_arrayref($statement) failed!\n";
print "DBI::err=[$DBI::err]\n";
print "DBI::errstr=[$DBI::errstr]\n";
exit;
}
my @resSet = @{$result};
if ( $#resSet == -1 ) {
print "no results\n";
exit;
}
foreach my $row ( @{ $result } ) {
my @result = @{ $row };
print EXTEN "$result[0]=$result[1]\n";
}
print EXTEN "$additional\n";
}
exit 0;
This diff is collapsed.
drop table if exists users;
create table users (mailbox VARCHAR(80) NOT NULL PRIMARY KEY, context VARCHAR(80), password VARCHAR(80), fullname VARCHAR(80), email VARCHAR(80), pager VARCHAR(80), options VARCHAR(160));
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment