From bcc72e4d4f05b7c16923e84ce712f2ac1904fa24 Mon Sep 17 00:00:00 2001 From: lmadsen Date: Tue, 20 Jan 2009 21:00:59 +0000 Subject: Creating tag for the asterisk-1.4.23 release git-svn-id: http://svn.digium.com/svn/asterisk/tags/1.4.23@169569 f38db490-d61c-443f-a65b-d21fe96a405b --- contrib/scripts/README.messages-expire | 20 - contrib/scripts/agents.php | 73 -- contrib/scripts/ast_grab_core | 70 -- contrib/scripts/astgenkey | 61 -- contrib/scripts/astgenkey.8 | 144 --- contrib/scripts/autosupport | 255 ----- contrib/scripts/autosupport.8 | 41 - contrib/scripts/get_ilbc_source.sh | 33 - contrib/scripts/iax-friends.sql | 54 - contrib/scripts/loadtest.tcl | 148 --- contrib/scripts/lookup.agi | 90 -- contrib/scripts/managerproxy.pl | 242 ----- contrib/scripts/meetme.sql | 12 - contrib/scripts/messages-expire.pl | 96 -- contrib/scripts/qview.pl | 100 -- contrib/scripts/realtime_pgsql.sql | 142 --- contrib/scripts/retrieve_extensions_from_mysql.pl | 113 -- contrib/scripts/retrieve_extensions_from_sql.pl | 158 --- contrib/scripts/retrieve_sip_conf_from_mysql.pl | 93 -- contrib/scripts/safe_asterisk | 178 ---- contrib/scripts/safe_asterisk.8 | 69 -- contrib/scripts/safe_asterisk_restart | 110 -- contrib/scripts/sip-friends.sql | 54 - contrib/scripts/vmail.cgi | 1140 --------------------- contrib/scripts/vmdb.sql | 64 -- 25 files changed, 3560 deletions(-) delete mode 100644 contrib/scripts/README.messages-expire delete mode 100644 contrib/scripts/agents.php delete mode 100644 contrib/scripts/ast_grab_core delete mode 100644 contrib/scripts/astgenkey delete mode 100644 contrib/scripts/astgenkey.8 delete mode 100644 contrib/scripts/autosupport delete mode 100644 contrib/scripts/autosupport.8 delete mode 100755 contrib/scripts/get_ilbc_source.sh delete mode 100644 contrib/scripts/iax-friends.sql delete mode 100644 contrib/scripts/loadtest.tcl delete mode 100644 contrib/scripts/lookup.agi delete mode 100644 contrib/scripts/managerproxy.pl delete mode 100644 contrib/scripts/meetme.sql delete mode 100644 contrib/scripts/messages-expire.pl delete mode 100644 contrib/scripts/qview.pl delete mode 100644 contrib/scripts/realtime_pgsql.sql delete mode 100644 contrib/scripts/retrieve_extensions_from_mysql.pl delete mode 100644 contrib/scripts/retrieve_extensions_from_sql.pl delete mode 100644 contrib/scripts/retrieve_sip_conf_from_mysql.pl delete mode 100644 contrib/scripts/safe_asterisk delete mode 100644 contrib/scripts/safe_asterisk.8 delete mode 100644 contrib/scripts/safe_asterisk_restart delete mode 100644 contrib/scripts/sip-friends.sql delete mode 100644 contrib/scripts/vmail.cgi delete mode 100644 contrib/scripts/vmdb.sql (limited to 'contrib/scripts') diff --git a/contrib/scripts/README.messages-expire b/contrib/scripts/README.messages-expire deleted file mode 100644 index 12f2b0e9c..000000000 --- a/contrib/scripts/README.messages-expire +++ /dev/null @@ -1,20 +0,0 @@ -messages-expire.pl - -messages-expire 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. diff --git a/contrib/scripts/agents.php b/contrib/scripts/agents.php deleted file mode 100644 index 51f8bdee3..000000000 --- a/contrib/scripts/agents.php +++ /dev/null @@ -1,73 +0,0 @@ - 'Unknown', - 'AGENT_IDLE' => 'Idle', - 'AGENT_ONCALL' => 'On Call', - 'AGENT_LOGGEDOFF' => 'Not Logged In' ); - -if(!$socket) { - print "Couldn't open socket. Error #" . $errornum . ": " . $errorstr; -} else { - fputs($socket, "Action: Login\r\n"); - fputs($socket, "UserName: $username\r\n"); - fputs($socket, "Secret: $secret\r\n\r\n"); - fputs($socket, "Action: Agents\r\n\r\n"); - fputs($socket, "Action: Logoff\r\n\r\n"); - - while(!feof($socket)) { - $info = fscanf($socket, "%s\t%s\r\n"); - switch($info[0]) { - case "Agent:": - $curr_agent = $info[1]; - $agents[$curr_agent] = array(); - break; - case "Name:": - $agents[$curr_agent]['Name'] = $info[1]; - break; - case "Status:": - $agents[$curr_agent]['Status'] = $better_status[$info[1]]; - break; - case "LoggedInChan:": - $agents[$curr_agent]['LoggedInChan'] = $info[1]; - break; - case "LoggedInTime:": - if($info[1] != "0") { - $agents[$curr_agent]['LoggedInTime'] = date("D, M d Y g:ia", $info[1]); - } else { - $agents[$curr_agent]['LoggedInTime'] = "n/a"; - } - break; - case "TalkingTo:": - $agents[$curr_agent]['TalkingTo'] = $info[1]; - break; - default: - break; - } - } - fclose($socket); - - print "Agents Status\n\n"; - print "\n"; - print " \n"; - - foreach( $agents as $agent=>$curr ) { - print " \n \n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print " \n \n"; - } - - print "
Agent #Agent NameAgent LocationAgent StatusAgent Talking ToAgent Login Time
" . $agent . "" . $curr['Name'] . "" . $curr['LoggedInChan'] . "" . $curr['Status'] . "" . $curr['TalkingTo'] . "" . $curr['LoggedInTime'] . "
\n\n\n"; -} -?> diff --git a/contrib/scripts/ast_grab_core b/contrib/scripts/ast_grab_core deleted file mode 100644 index b2bd7b2ed..000000000 --- a/contrib/scripts/ast_grab_core +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/sh -# $Id$ -# lame quickie script to snarf a core of a hung asterisk process. -# bugs to ast_grab_core, blinky-lights.org (derrick daugherty) - -# we have found that gcore doesn't yield as useful a core file -# as that yielded by a signal-caused core dump. So we are going to change -# the strategy to sending a SEGV signal to the asterisk process, -# and have it 'burn to the ground', leaving behind a core file. -# the main difference is that you cannot control where the -# core file will end up. We will assume that safe_asterisk was -# used to start asterisk, and the core file should therefore end -# up in /tmp (because safe_asterisk cd's there before starting asterisk). -# if this is not the case, set DUMPDIR to the place where the core -# file can be found. - -DATE=`date +%Y%m%d%H%M` -DUMPDIR=/tmp -HOSTNAME=`hostname` -ADMINEMAIL="root@localhost" - -#the following should be improved -if [ -e /etc/asterisk/asterisk.conf ]; then - RUNDIR=`awk -F"=>" '/astrundir/ {print $2}' /etc/asterisk/asterisk.conf` - PID=`cat ${RUNDIR}/asterisk.pid` -elif [ -e /var/run/asterisk.pid ] ; then - PID=`cat /var/run/asterisk.pid` -else - echo Could not find an asterisk.conf definition for astrundir, using \'ps\' - echo to try and determine process ID. This is not reliable. - PID=`ps auxwf|grep asterisk|grep vv|head -1|awk '{print $2}'` -fi - -echo Snarfing asterisk core, this could take a few seconds depending -echo on how much memory is in use. -echo -echo \*\*\* WARNING \*\*\* If the system is not already locked this will cause the -echo \*\*\* WARNING \*\*\* process to STOP while memory is dumped to disk. -echo - -/bin/kill -11 ${PID} - -echo Snarfed! ${DUMPDIR}/core.${PID} -echo - - -echo Trying for a backtrace of the captured core. -/usr/bin/gdb /usr/sbin/asterisk ${DUMPDIR}/core.${PID} > ${DUMPDIR}/gdb_dump.${PID}.txt 2> /dev/null << EOF -set prompt \n -set print pretty\n -echo --------------------------------------------------------------------------------\n -echo INFO THREAD -info thread -echo --------------------------------------------------------------------------------\n -echo THREAD APPLY ALL BT -thread apply all bt -echo --------------------------------------------------------------------------------\n -echo THREAD APPLY ALL BT FULL -thread apply all bt full -quit -EOF -echo Done trying for a bt. - - -echo Notifying admins of the core. -/usr/bin/mail -s "${HOSTNAME} core dumped at ${DUMPDIR}/core.${PID}" ${ADMINEMAIL} < ${DUMPDIR}/gdb_dump.${PID}.txt -echo Done. -echo -echo Reproducible deadlocks should be posted with a full backtrace and instructions -echo to reproduce the issue at http://bugs.digium.com/ Thanks! diff --git a/contrib/scripts/astgenkey b/contrib/scripts/astgenkey deleted file mode 100644 index 637604896..000000000 --- a/contrib/scripts/astgenkey +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/sh -# -# Usage: astgenkey [ -q ] [ -n ] [keyname] -# -DES3=-des3 -if [ "$1" = "-q" ]; then - QUIET='y' - if [ "$2" = "-n" ]; then - DES3= - KEY=$3 - else - KEY=$2 - fi -elif [ "$1" = "-n" ]; then - DES3= - if [ "$2" = "-q" ]; then - QUIET='y' - KEY=$3 - else - KEY=$2 - fi -else - KEY=$1 -fi - -if [ "$QUIET" != 'y' ]; then - echo "" - echo "This script generates an RSA private and public key pair" - echo "in PEM format for use by Asterisk. You will be asked to" - echo "enter a passcode for your key multiple times. Please" - echo "enter the same code each time. The resulting files will" - echo "need to be moved to /var/lib/asterisk/keys if you want" - echo "to use them, and any private keys (.key files) will" - echo "need to be initialized at runtime either by running" - echo "Asterisk with the '-i' option, or with the 'init keys'" - echo "command once Asterisk is running." - echo "" - echo "Press ENTER to continue or ^C to cancel." - read BLAH -fi - -while [ "$KEY" = "" ]; do - echo -n "Enter key name: " - read KEY -done - -rm -f ${KEY}.key ${KEY}.pub - -echo "Generating SSL key '$KEY': " -openssl genrsa -out ${KEY}.key ${DES3} 1024 -openssl rsa -in ${KEY}.key -pubout -out ${KEY}.pub - -if [ -f "${KEY}.key" ] && [ -f "${KEY}.pub" ]; then - if [ "$QUIET" != 'y' ]; then - echo "Key creation successful." - echo "Public key: ${KEY}.pub" - echo "Private key: ${KEY}.key" - fi -else - echo "Unknown error creating keys." -fi diff --git a/contrib/scripts/astgenkey.8 b/contrib/scripts/astgenkey.8 deleted file mode 100644 index 328a4d259..000000000 --- a/contrib/scripts/astgenkey.8 +++ /dev/null @@ -1,144 +0,0 @@ -.\" $Header$ -.\" -.\" transcript compatibility for postscript use. -.\" -.\" synopsis: .P! -.\" -.de P! -.fl -\!!1 setgray -.fl -\\&.\" -.fl -\!!0 setgray -.fl \" force out current output buffer -\!!save /psv exch def currentpoint translate 0 0 moveto -\!!/showpage{}def -.fl \" prolog -.sy sed \-e 's/^/!/' \\$1\" bring in postscript file -\!!psv restore -. -.de pF -.ie \\*(f1 .ds f1 \\n(.f -.el .ie \\*(f2 .ds f2 \\n(.f -.el .ie \\*(f3 .ds f3 \\n(.f -.el .ie \\*(f4 .ds f4 \\n(.f -.el .tm ? font overflow -.ft \\$1 -.. -.de fP -.ie !\\*(f4 \{\ -. ft \\*(f4 -. ds f4\" -' br \} -.el .ie !\\*(f3 \{\ -. ft \\*(f3 -. ds f3\" -' br \} -.el .ie !\\*(f2 \{\ -. ft \\*(f2 -. ds f2\" -' br \} -.el .ie !\\*(f1 \{\ -. ft \\*(f1 -. ds f1\" -' br \} -.el .tm ? font underflow -.. -.ds f1\" -.ds f2\" -.ds f3\" -.ds f4\" -'\" t -.ta 8n 16n 24n 32n 40n 48n 56n 64n 72n -.TH ASTGENKEY 8 "May 14th, 2005" "Asterisk" "Linux Programmer's Manual" -.SH NAME -.B astgenkey --- generates keys for for Asterisk IAX2 RSA authentication -.SH SYNOPSIS -.PP -.B astgenkey -[ -q ] [ -n ] [ \fIkeyname\fP ] - -.SH DESCRIPTION -.B astgenkey -This script generates an RSA private and public key pair in PEM format -for use by Asterisk. The private key should be kept a secret, as it can -be used to fake your system's identity. Thus by default (without the -option -.I -n -) the script will create a passphrase-encrypted copy of your secret key: -without entering the passphrase you won't be able to use it. - -However if you want to use such a key with Asterisk, you'll have to start -it interactively, because the scripts that start asterisk can't use that -encrypted key. - -The key is identified by a name. If you don't write the name on the -command-line you'll be prompted for one. The outputs of the script are: - -.I name\fB.pub -.RS -The public key: not secret. Send this to the other side. -.RE - -.I name\fB.key -.RS -The private key: secret. -.RE - -Those files should be copied to -.I /var/lib/asterisk/keys - -(The private key: on your system. The public key: on other systems) - -To see the currently-installed keys from the asterisk CLI, use the command - -.RS -show keys -.RE - -.SH OPTIONS -.B -q -.RS -Run quietly. -.RE - -.B -n -.RS -Don't encrypt the private key. -.RE - -.SH SECURITY -The keys are created, using the umask of the user running the command. -To create the keys in a secure manner, you should check to ensure that -your umask is first set to disallow the private key from being world- -readable, such as with the following commands: - -.I umask 0066 - -.I astgenkey yourkey - -And then make the key accessible to Asterisk (assuming you run it as -user "asterisk"). - - chown asterisk /var/lib/asterisk/keys/yourname.* - -.SH FILES -.I /var/lib/asterisk/keys -.RS -.RE - -.SH "SEE ALSO" -asterisk(8), genrsa(1), rsa(1), - -http://www.voip-info.org/wiki-Asterisk+iax+rsa+auth - -.SH "AUTHOR" -This manual page was written by Tzafrir Cohen -Permission is granted to copy, distribute and/or modify this document under -the terms of the GNU General Public License, Version 2 any -later version published by the Free Software Foundation. - -On Debian systems, the complete text of the GNU General Public -License can be found in /usr/share/common-licenses/GPL. diff --git a/contrib/scripts/autosupport b/contrib/scripts/autosupport deleted file mode 100644 index d055ac7d4..000000000 --- a/contrib/scripts/autosupport +++ /dev/null @@ -1,255 +0,0 @@ -#!/bin/sh -# -# Collect support information -# -# Copyright (C) 2005, Digium, Inc. -# -# Written by John Bigelow (support@digium.com) -# -# Distributed under the terms of the GNU General Public -# License -# - -OUTPUT=$HOME/digiuminfo - -MYUID=$(id -u); - -if [ $MYUID -ne 0 ]; then - - echo "You must be root to run this." - exit 1 -fi - -clear - -echo -echo "This will gather information about your system such as:" -echo "pci listing, dmesg, running processes, and kernel version" -echo "This may take up to half a minute to run. Please be patient." -echo "To continue press 'y', to quit press any other key" -read ans - -if [ "$ans" = "y" ]; then - - rm -f $OUTPUT - - echo "------------------" >> $OUTPUT; - echo "PCI LIST" >> $OUTPUT; - echo "------------------" >> $OUTPUT; - lspci -vvvb >> $OUTPUT; - echo >> $OUTPUT; - echo >> $OUTPUT; - - echo "------------------" >> $OUTPUT; - echo "PCI LIST(no lookup)" >> $OUTPUT; - echo "------------------" >> $OUTPUT; - lspci -vvvbn >> $OUTPUT; - echo >> $OUTPUT; - echo >> $OUTPUT; - - echo "------------------" >> $OUTPUT; - echo "INTERRUPTS" >> $OUTPUT; - echo "------------------" >> $OUTPUT; - cat /proc/interrupts >> $OUTPUT; - echo >> $OUTPUT; - echo >> $OUTPUT; - - echo "------------------" >> $OUTPUT; - echo "RUNNING PROCESSES" >> $OUTPUT; - echo "------------------" >> $OUTPUT; - ps aux >> $OUTPUT; - echo >> $OUTPUT; - echo >> $OUTPUT; - - echo "------------------" >> $OUTPUT; - echo "KERNEL VERSION" >> $OUTPUT; - echo "------------------" >> $OUTPUT; - uname -a >> $OUTPUT; - echo >> $OUTPUT; - echo >> $OUTPUT; - - echo "------------------" >> $OUTPUT; - echo "CPU INFO" >> $OUTPUT; - echo "------------------" >> $OUTPUT; - cat /proc/cpuinfo >> $OUTPUT; - echo >> $OUTPUT; - echo >> $OUTPUT; - - echo "------------------" >> $OUTPUT; - echo "VERSION INFO" >> $OUTPUT; - echo "------------------" >> $OUTPUT; - cat /proc/version >> $OUTPUT; - echo >> $OUTPUT; - echo >> $OUTPUT; - - echo "------------------" >> $OUTPUT; - echo "CMDLINE INFO" >> $OUTPUT; - echo "------------------" >> $OUTPUT; - cat /proc/cmdline >> $OUTPUT; - echo >> $OUTPUT; - echo >> $OUTPUT; - - echo "------------------" >> $OUTPUT; - echo "KERNEL CONFIG" >> $OUTPUT; - echo "------------------" >> $OUTPUT; - echo "/lib/modules/$(uname -r)/build/.config:" >> $OUTPUT; - cat /lib/modules/$(uname -r)/build/.config >> $OUTPUT; - echo >> $OUTPUT; - echo "/usr/src/linux/.config:" >> $OUTPUT; - cat /usr/src/linux/.config >> $OUTPUT; - echo >> $OUTPUT; - echo >> $OUTPUT; - - echo "------------------" >> $OUTPUT; - echo "ZAPTEL MODULE INFO" >> $OUTPUT; - echo "------------------" >> $OUTPUT; - modinfo /lib/modules/$(uname -r)/misc/*.ko >> $OUTPUT; - echo >> $OUTPUT; - echo >> $OUTPUT; - - echo "------------------" >> $OUTPUT; - echo "DAHDI MODULE INFO" >> $OUTPUT; - echo "------------------" >> $OUTPUT; - modinfo /lib/modules/$(uname -r)/dahdi/*.ko >> $OUTPUT; - echo >> $OUTPUT; - echo >> $OUTPUT; - - echo "------------------" >> $OUTPUT; - echo "OTHER INFO" >> $OUTPUT; - echo "------------------" >> $OUTPUT; - echo "/etc/*issues*:" >> $OUTPUT; - cat /etc/*issues* >> $OUTPUT; - echo >> $OUTPUT; - echo "/etc/*release*:" >> $OUTPUT; - cat /etc/*release* >> $OUTPUT; - echo >> $OUTPUT; - echo "/etc/*motd*:" >> $OUTPUT; - cat /etc/*motd* >> $OUTPUT; - echo >> $OUTPUT; - echo >> $OUTPUT; - - echo "------------------" >> $OUTPUT; - echo "LOADED MODULES" >> $OUTPUT; - echo "------------------" >> $OUTPUT; - lsmod >> $OUTPUT; - echo >> $OUTPUT; - echo >> $OUTPUT; - - echo "------------------" >> $OUTPUT; - echo "ZTTEST" >> $OUTPUT; - echo "------------------" >> $OUTPUT; - zttest -c 20 >> $OUTPUT; - echo >> $OUTPUT; - echo >> $OUTPUT; - - echo "------------------" >> $OUTPUT; - echo "DAHDI_TEST" >> $OUTPUT; - echo "------------------" >> $OUTPUT; - dahdi_test -c 20 >> $OUTPUT; - echo >> $OUTPUT; - echo >> $OUTPUT; - - echo "------------------" >> $OUTPUT; - echo "DMESG OUTPUT" >> $OUTPUT; - echo "------------------" >> $OUTPUT; - dmesg >> $OUTPUT; - echo >> $OUTPUT; - echo >> $OUTPUT; - - echo "------------------" >> $OUTPUT; - echo "DMIDECODE" >> $OUTPUT; - echo "------------------" >> $OUTPUT; - dmidecode >> $OUTPUT; - echo >> $OUTPUT; - echo >> $OUTPUT; - - echo "------------------" >> $OUTPUT; - echo "ZAPTEL CONFIG" >> $OUTPUT; - echo "------------------" >> $OUTPUT; - grep -v '^#' /etc/zaptel.conf >> $OUTPUT; - echo >> $OUTPUT; - echo >> $OUTPUT; - - echo "------------------" >> $OUTPUT; - echo "DAHDI CONFIG" >> $OUTPUT; - echo "------------------" >> $OUTPUT; - grep -v '^#' /etc/dahdi/system.conf >> $OUTPUT; - echo >> $OUTPUT; - echo >> $OUTPUT; - - echo "------------------" >> $OUTPUT; - echo "ZAPATA CONFIG" >> $OUTPUT; - echo "------------------" >> $OUTPUT; - grep -v '^;' /etc/asterisk/zapata.conf >> $OUTPUT; - echo >> $OUTPUT; - echo >> $OUTPUT; - - echo "------------------" >> $OUTPUT; - echo "CHAN_DAHDI CONFIG" >> $OUTPUT; - echo "------------------" >> $OUTPUT; - grep -v '^;' /etc/asterisk/chan_dahdi.conf >> $OUTPUT; - echo >> $OUTPUT; - echo >> $OUTPUT; - - echo "------------------" >> $OUTPUT; - echo "EXTENSIONS CONFIG" >> $OUTPUT; - echo "------------------" >> $OUTPUT; - grep -v '^;' /etc/asterisk/extensions.conf >> $OUTPUT; - echo >> $OUTPUT; - echo >> $OUTPUT; - -else - echo "terminated"; -exit -fi - -clear - -echo -echo "Digium may require root level access to the system to help debug"; -echo "the problem you are experiencing. Do you want to provide login"; -echo "information at this time? Please note that if you do so, change"; -echo "your root password to a secure temporary password for Digium support"; -echo "Press 'y' for yes and any other key to exit and save the previous info collected" -read login - -if [ "$login" = "y" ]; then - - echo "------------------" >> $OUTPUT; - echo "LOGIN INFORMATION" >> $OUTPUT; - echo "------------------" >> $OUTPUT; - - echo - echo "What is your root password?" - read rootpass - - echo - echo "Root pass: "$rootpass >> $OUTPUT - - echo - echo "What is your PUBLIC IP address?" - read ip - - echo "IP address: "$ip >> $OUTPUT - - echo - echo "Please provide any other login information that the technician" - echo "may need to know to login to the system'(press enter if not)'" - read adinfo - - echo "Additional login info: "$adinfo >> $OUTPUT - - clear - echo - echo "All information has been stored in $OUTPUT," - echo "Please attach this file to an email case you already" - echo "have open with Digium Tech Support." - -else - clear - echo - echo "All information except login info has been stored in $OUTPUT," - echo "Please send this file to an email case you already" - echo "have open with Digium Tech Support." -exit -fi diff --git a/contrib/scripts/autosupport.8 b/contrib/scripts/autosupport.8 deleted file mode 100644 index e356fcdbb..000000000 --- a/contrib/scripts/autosupport.8 +++ /dev/null @@ -1,41 +0,0 @@ -.TH AUTOSUPPORT 8 "Jul 5th, 2005" "Asterisk" "Linux Programmer's Manual" -.SH NAME -.B autosupport -\(em interactive script to provide Digium[tm]'s support with information -.SH SYNOPSIS -.PP -.B autosupport - -.SH DESCRIPTION -.B autoasupport -is a script that is normally run by a user contacting Digium's support -to automate gathering support information. - -It will probe the system for some configuration and run-time information, -and will also prompt the user for some optional access information (IP -address, login and password). - -The information is written to /root/digiuminfo which the user is expected -to attach to a support ticket to Digium. - -The script must be run as root as it reads Asterisk's configuration and -the disk information using hdparm(8). - -.SH FILES -.B /root/digiuminfo -.RS -The output of the script goes there -.RE - -.SH SEE ALSO -asterisk(8) - -.SH "AUTHOR" -autosupport was written by John Bigelow . -This manual page was written by Tzafrir Cohen -Permission is granted to copy, distribute and/or modify this document under -the terms of the GNU General Public License, Version 2 any -later version published by the Free Software Foundation. - -On Debian systems, the complete text of the GNU General Public -License can be found in /usr/share/common-licenses/GPL. diff --git a/contrib/scripts/get_ilbc_source.sh b/contrib/scripts/get_ilbc_source.sh deleted file mode 100755 index fd7bac12e..000000000 --- a/contrib/scripts/get_ilbc_source.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -e - -if [ -f codecs/ilbc/iLBC_define.h ]; then - echo "***" - echo "The iLBC source code appears to already be present and does not" - echo "need to be downloaded." - echo "***" - - exit 1 -fi - -echo "***" -echo "This script will download the Global IP Solutions iLBC encoder/decoder" -echo "source code from http://ilbcfreeware.org. Use of this code requires" -echo "agreeing to the license agreement present at that site." -echo "" -echo "This script assumes that you have already agreed to the license agreement." -echo "If you have not done so, you can abort the script now." -echo "***" - -read tmp - -wget -P codecs/ilbc http://www.ietf.org/rfc/rfc3951.txt - -wget -q -O - http://www.ilbcfreeware.org/documentation/extract-cfile.awk | sed -e 's/\r//g' > codecs/ilbc/extract-cfile.awk - -(cd codecs/ilbc && awk -f extract-cfile.awk rfc3951.txt) - -echo "***" -echo "The iLBC source code download is complete." -echo "***" - -exit 0 diff --git a/contrib/scripts/iax-friends.sql b/contrib/scripts/iax-friends.sql deleted file mode 100644 index 9f8cd5ccd..000000000 --- a/contrib/scripts/iax-friends.sql +++ /dev/null @@ -1,54 +0,0 @@ -# -# Table structure for table `iaxfriends` -# - -CREATE TABLE `iaxfriends` ( - `name` varchar(40) NOT NULL default '', - `username` varchar(40) NOT NULL default '', - `secret` varchar(40) NOT NULL default '', - `dbsecret` varchar(40) NOT NULL default '', - `context` varchar(40) NOT NULL default '', - `regcontext` varchar(40) NOT NULL default '', - `host` varchar(40) NOT NULL default 'dynamic', - `ipaddr` varchar(20) NOT NULL default '', - `port` int(6) NOT NULL default '0', - `defaultip` varchar(20) NOT NULL default '', - `sourceaddress` varchar(20) NOT NULL default '', - `mask` varchar(20) NOT NULL default '', - `regexten` varchar(40) NOT NULL default '', - `regseconds` int(11) NOT NULL default '0', - `accountcode` varchar(20) NOT NULL default '', - `mohinterpret` varchar(20) NOT NULL default '', - `mohsuggest` varchar(20) NOT NULL default '', - `inkeys` varchar(40) NOT NULL default '', - `outkey` varchar(40) NOT NULL default '', - `language` varchar(10) NOT NULL default '', - `callerid` varchar(40) NOT NULL default '', - `cid_number` varchar(40) NOT NULL default '', - `sendani` varchar(10) NOT NULL default '', - `fullname` varchar(40) NOT NULL default '', - `trunk` varchar(10) NOT NULL default '', - `auth` varchar(20) NOT NULL default '', - `maxauthreq` varchar(15) NOT NULL default '', - `encryption` varchar(20) NOT NULL default '', - `transfer` varchar(10) NOT NULL default '', - `jitterbuffer` varchar(10) NOT NULL default '', - `forcejitterbuffer` varchar(10) NOT NULL default '', - `disallow` varchar(40) NOT NULL default 'all', - `allow` varchar(40) NOT NULL default '', - `codecpriority` varchar(40) NOT NULL default '', - `qualify` varchar(10) NOT NULL default '', - `qualifysmoothing` varchar(10) NOT NULL default '', - `qualifyfreqok` varchar(10) NOT NULL default '', - `qualifyfreqnotok` varchar(10) NOT NULL default '', - `timezone` varchar(20) NOT NULL default '', - `adsi` varchar(10) NOT NULL default '', - `amaflags` varchar(20) NOT NULL default '', - `setvar` varchar(200) NOT NULL default '', - PRIMARY KEY (`name`), - INDEX name (name, host), - INDEX name2 (name, ipaddr, port), - INDEX ipaddr (ipaddr, port), - INDEX host (host, port), -) TYPE=MyISAM; - diff --git a/contrib/scripts/loadtest.tcl b/contrib/scripts/loadtest.tcl deleted file mode 100644 index 9c50be338..000000000 --- a/contrib/scripts/loadtest.tcl +++ /dev/null @@ -1,148 +0,0 @@ -#!/usr/bin/tclsh -# -# Usage (as root): -# -# $ tclsh loadtest.tcl -# -# Copyleft 2005 by Chris Maj -# -# Create a (huge) bunch of call files to dial via pbx_spool. -# Defaults are selected with 'Enter' and, if all defaults -# are selected, you'll dial Zap/1/s into default|s|1 -# - - -# where Asterisk's pbx/pbx_spool.c will be looking for work -set SPOOLDIR /var/spool/asterisk/outgoing -# pbx_spool is fairly aggresive, so make files here first -set TEMPDIR /tmp - -if { ![file writable $SPOOLDIR] } { - puts "Do you need to be root to write to $SPOOLDIR ?" - exit -} - -if { ![file readable $TEMPDIR] } { - puts "Do you need to be root to read from $TEMPDIR ?" - exit -} - -if { ![file writable $TEMPDIR] } { - puts "Do you need to be root to write to $TEMPDIR ?" - exit -} - -# gets some input from the user -proc get {var_ default_ prompt_} { - global $var_ - puts $prompt_ - if { $default_ != "" } { - puts -nonewline "(default: $default_) ? " - } else { - puts -nonewline "? " - } - flush stdout - gets stdin $var_ - if { [set $var_] == "" && $default_ != "" } { - set $var_ $default_ - } -} - -# puts the user requested channels into a neat, ordered list -proc splitchans {inch_} { - global changroup - set outch [list] - foreach range [split $inch_ {, }] { - set start [lindex [split $range -] 0] - set stop [lindex [split $range -] end] - if { [string is digit $start] && [string is digit $stop] } { - set ::changroup "channel" - for {set ch $start} {$ch <= $stop} {incr ch} { - if { [lsearch $outch $ch] == -1 } { - lappend outch $ch - } - } - } else { - set ::changroup "group" - foreach ch [split $range -] { - lappend outch $ch - } - } - } - return [lsort -dictionary $outch] -} - -# writes out a file in the temporary directory, -# then changes the mtime of the file before -# sticking it into the outgoing spool directory -# (where pbx_spool will be looking) -proc spool {channel_ callcnt_ when_} { - set callstr " -Channel: $::technology/$channel_/$::destination -Context: $::context -Extension: $::extension -Priority: $::priority -WaitTime: $::timeout -RetryTime: $::retrytime -MaxRetries: $::maxretries -Callerid: $::clid -SetVar: $::astvar -Account: $::account -" - set fn "loadtest.call$callcnt_.ch$channel_" - set fd [open $::TEMPDIR/$fn w] - puts $fd $callstr - close $fd - file mtime $::TEMPDIR/$fn $when_ - file rename -force $::TEMPDIR/$fn $::SPOOLDIR/$fn -} - -# prompt the user for some info -get technology "Zap" "\nEnter technology type -Zap, IAX, SIP, etc." -get chans "1" "\nEnter channel(s) or group to test in formats like -2\n1-4\n3 5 7 9\n1-23,25-47,49-71,73-95\ng4\ng2,g1" -set channels [splitchans $chans] - -get destination "s" "\nEnter destination number" -get context "default" "\nEnter context" -get extension "s" "\nEnter extension" -get priority "1" "\nEnter priority" -get timeout "45" "\nEnter timeout for call to be answered in seconds" -get maxretries "0" "\nEnter maximum number of retries" - -if { $maxretries > 0 } { - get retrytime "300" "\nEnter time between retries in seconds" -} else { - set retrytime 300 -} - -get clid "" "\nEnter callerid" -get astvar "" "\nEnter some extra variables" -get account "loadtest" "\nEnter account code" -get calls "1" "\nEnter number of test calls per $changroup" -get period "60" "\nEnter period between placing calls on a particular $changroup in seconds" - -if { [llength $channels] > 1 } { - get rate "0" "\nEnter period between placing each call in seconds -0 will send a call on each $changroup every $period seconds -1 will send a call on $changroup [lindex $channels 0] at [expr {$period + 0}]s, [lindex $channels 1] at [expr {$period + 1 }]s, etc. -5 will send a call on $changroup [lindex $channels 0] at [expr {$period + 0}]s, [lindex $channels 1] at [expr {$period + 5 }]s, etc." -} else { - set rate 0 -} - -puts -nonewline "\nCreating spooled call files... " -set now [clock seconds] -set spoolcnt 0 -set spinner [list / - \\ |] -for {set i 0} {$i < $calls} {incr i} { - foreach ch $channels { - set chidx [lsearch $channels $ch] - spool $ch [incr spoolcnt] [expr {$now + ($i * $period) + ($rate * $chidx)}] - puts -nonewline "\b" - puts -nonewline [lindex $spinner [expr {$spoolcnt % 4}]] - flush stdout - } -} -puts "\b$spoolcnt calls placed into $SPOOLDIR !" diff --git a/contrib/scripts/lookup.agi b/contrib/scripts/lookup.agi deleted file mode 100644 index 4b682b837..000000000 --- a/contrib/scripts/lookup.agi +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/perl -# -# Use Reverse Lookups to populate valuable information -# -# Copyright (C) 2005 Digium, Inc. -# -# Mark Spencer -# -# Based on work of Joe Fratantoni - BrakeDanceJ - Joe@UnrealDestination.com. -# -# This program is Free Software distributed under the terms of the GNU -# General Public License version 2. See LICENSE for details. -# -# -use LWP::UserAgent; -my %AGI; -my $debug = 0; -$|=1; -sub url_decode { - my @args = @_; - s/%([0-9A-F]{2})/chr hex $1/egios for @args; - s/\"//egios for @args; - return wantarray ? @args : $args[0]; -} - -while() { - chomp; - last unless length($_); - if (/^agi_(\w+)\:\s+(.*)$/) { - $AGI{$1} = $2; - } -} - -alarm(4); -my $number = $AGI{'callerid'}; -$number =~ /(\d+)/; -$number = $1; -die("You must specify a number") unless $number; -my $ua = LWP::UserAgent->new; -$ua->agent("Asterisk"); -my $req = HTTP::Request->new(POST => 'http://www.411.com/10668/search/Reverse_Phone'); -$req->content_type('application/x-www-form-urlencoded'); -$req->content("phone=$number"); -my $res = $ua->request($req); -if ($res->is_success) { - my $first, $last, $address, $street, $house, $city, $state, $zip, $phone; - if ($res->content =~ /PAGE: PHONE_NOT_FOUND/) { - # Limited Information - $res->content =~ /is a \s+([A-Za-z -]*), ([A-Z]{2}) \s+based phone number and the registered carrier is (.*)\.\s+/; - ($city, $state, $last) = - map { url_decode($_) } ($1, $2, $3); - $cidname = "$city, $state"; - } else { - # Full Information - $res->content =~ /RM_HTML_FIRST_ESC_=(.*)&_RM_HTML_LAST_ESC_=(.*)&_RM_HTML_ADDRESS_ESC_=(.*)&_RM_HTML_STREET_ESC_=(.*)&_RM_HTML_HOUSE_ESC_=(.*)&_RM_HTML_CITY_ESC_=(.*)&_RM_HTML_STATE_ESC_=(.*)&_RM_HTML_ZIP_ESC_=(.*)&_RM_HTML_PHONE_ESC_=(.*)&CITY=(.*)&STATE=(.*)/; - ($first, $last, $address, $street, $house, $city, $state, $zip, $phone) = - map { url_decode($_) } ($1, $2, $3, $4, $5, $6, $7, $8, $9); - my $cidname = $last; - if ($first) { - $cidname = $first . " " . $last; - } else { - $cidname = $last; - } - } - print STDOUT "SET VARIABLE CALLERID(name) \"$cidname\"\n"; - ; - print STDOUT "SET VARIABLE CALLER_ZIP \"$zip\"\n"; - ; - print STDOUT "SET VARIABLE CALLER_STATE \"$state\"\n"; - ; - print STDOUT "SET VARIABLE CALLER_CITY \"$city\"\n"; - ; - print STDOUT "SET VARIABLE CALLER_ADDRESS \"$address\"\n"; - ; - print STDOUT "SET VARIABLE CALLER_LAST \"$last\"\n"; - ; - print STDOUT "SET VARIABLE CALLER_FIRST \"$first\"\n"; - ; - print STDERR "First: $first\n" . - "Last: $last\n" . - "Address: $address\n" . - "Street: $street\n" . - "House: $house\n" . - "City: $city\n" . - "State: $state\n" . - "Zip: $zip\n" . - "Phone: $phone\n" if $debug; -} else { - print STDERR $res->status_line . "\n"; -} diff --git a/contrib/scripts/managerproxy.pl b/contrib/scripts/managerproxy.pl deleted file mode 100644 index cdf79a239..000000000 --- a/contrib/scripts/managerproxy.pl +++ /dev/null @@ -1,242 +0,0 @@ -#!/usr/bin/perl -w -# -# Simple Asterisk Manager Proxy, Version 1.01 -# 2004-09-26 -# Copyright (c) 2004 David C. Troy -# -# This code is based on Flash Operator Panel 'op_server.pl' -# by Nicolas Gudino -#  Copyright (C) 2004. -# -# David C. Troy -# Nicolas Gudino -# -# This program is free software, distributed under the terms of -# the GNU General Public License. -# -# Security consideration: This script will open your manager port -# for unauthenticated logins. Be careful out there :-) -############################# - -############################# -# Perl Prerequisites -############################# -use strict; -use IO::Socket; -use IO::Select; -use POSIX qw(setsid); - -############################# -# User Configurable Options -############################# -# Configuration for logging in to your asterisk server -# Check you Asterisk config file "manager.conf" for details -my $manager_host = '127.0.0.1'; -my $manager_port = 5038; -my $manager_user = 'your_username'; -my $manager_secret = 'your_secret'; -# Port For this proxy -my $listen_port = 1234; -my $manager_pid = "/var/run/asterisk_managerproxy.pid"; - -############################# -# Declarations -############################# -my %proxy_clients; -my $O; -my $p; -my @S; -my %blocks; -my $debug = 0; - -$SIG{PIPE} = 'IGNORE'; -$SIG{INT} = 'close_all'; -$SIG{USR1} = 'list_clients'; - -if (defined($ARGV[0])) -{ - if ($ARGV[0] eq "-d") - { - defined(my $pid = fork) or die "Can't Fork: $!"; - exit if $pid; - setsid or die "Can't start a new session: $!"; - open MYPIDFILE, ">$manager_pid"; - print MYPIDFILE $$; - close MYPIDFILE; - } -} else { - $debug = 1; -} - - -# Connect to manager -$p = - new IO::Socket::INET->new( - PeerAddr => $manager_host, - PeerPort => $manager_port, - Proto => "tcp", - Type => SOCK_STREAM - ) - or die "\nCould not connect to Asterisk Manager Port at $manager_host\n"; - -$p->autoflush(1); - -# Login to Manager -send_command_to_manager( "Action: Login\r\nUsername: $manager_user\r\nSecret: $manager_secret\r\n\r\n" ); - -# Start up listener for new connections -my $m = - new IO::Socket::INET(Listen => 1, LocalPort => $listen_port, ReuseAddr => 1) - or die "\nCan't listen to port $listen_port\n"; -$O = new IO::Select(); -$O->add($m); -$O->add($p); -$/ = "\0"; - -sub manager_reconnect() -{ - my $attempt = 1; - my $total_attempts = 60; - - do - { - log_debug("** Attempt reconnection to manager port # $attempt", 16); - $p = - new IO::Socket::INET->new( - PeerAddr => $manager_host, - PeerPort => $manager_port, - Proto => "tcp", - Type => SOCK_STREAM - ); - $attempt++; - if ($attempt > $total_attempts) - { - die("!! Could not reconnect to Asterisk Manager port"); - } - sleep(10); # wait 10 seconds before trying to reconnect - } until $p; - $O->add($p); - send_command_to_manager( - "Action: Login\r\nUsername: $manager_user\r\nSecret: $manager_secret\r\n\r\n" - ); -} - -# Loop, continuously processing new connections, input from those connections, and input from Manager conn -while (1) -{ - while (@S = $O->can_read) - { - foreach (@S) - { - if ($_ == $m) - { - log_debug("** New client connection", 16); - my $C = $m->accept; - $proxy_clients{$C} = \$C; - print "New Connection: $C\n" if $debug; - $O->add($C); - } else { - # It's not a new client connection - my $i; - my $R = sysread($_, $i, 2); # 2048; interleave every two bytes? - if (defined($R) && $R == 0) - { - # Confirm it's really dead by trying to write to it? - my $T = syswrite($_, ' ', 2); # 2048 - if (!defined($T)) - { - # connection went away... - $O->remove($_); - $_->close; - - # If we lost the socket for the Asterisk Mgr, then reconnect - if ($_ == $p) - { - log_debug( - "** Asterisk Manager connection lost!!!!!", - 16); - manager_reconnect(); - } else { - # Remove handle from proxy_clients hash - print "Closed Connection: $_\n" if $debug; - delete $proxy_clients{$_}; - } - } - } - else # Socket is active and we are ready to read something from it - { - $blocks{$_} .= $i; - next if ($blocks{$_} !~ /\r\n\r\n$/); - # do a 'next' unless we have completed a block; we are not ready to continue - - # Process the completed block - # If block is from asterisk, send to clients - if ($_ == $p) { - # block is from asterisk, send to clients - print "asterisk: $_\n$blocks{$_}" if $debug; - my $cnt = 0; - foreach my $client (values %proxy_clients) { - print "writing to $$client...\n" if $debug; - syswrite($$client, $blocks{$_}); - $cnt++; - } - print "sent block to $cnt clients\n" if $debug; - } else { - # Blocks are from clients, send to asterisk - syswrite($p, $blocks{$_}); - print "client: $_\n$blocks{$_}\n" if $debug; - } - delete $blocks{$_}; - - } # end if read succeeded - } # end if new client connection - } # end foreach @S -> can read - } # while can read -} # endless loop - -sub close_all -{ - log_debug("Exiting...", 0); - - foreach my $hd ($O->handles) - { - $O->remove($hd); - close($hd); - } - - exit(0); -} - -sub send_command_to_manager -{ - my $comando = shift; - if (defined $p) - { - my @lineas = split("\r\n", $comando); - foreach my $linea (@lineas) - { - syswrite($p, "$linea\r\n"); - log_debug("-> $linea", 2); - } - log_debug(" ", 2); - syswrite($p, "\r\n"); - } -} - -sub log_debug -{ - my $texto = shift; - $texto =~ s/\0//g; - print "$texto\n" if $debug; -} - -sub list_clients() -{ - my $cnt = 0; - foreach my $client (values %proxy_clients) { - print "client: $$client\n"; - $cnt++; - } - print "$cnt clients.\n\n"; -} - diff --git a/contrib/scripts/meetme.sql b/contrib/scripts/meetme.sql deleted file mode 100644 index 19c4ed745..000000000 --- a/contrib/scripts/meetme.sql +++ /dev/null @@ -1,12 +0,0 @@ --- --- Table structure for Realtime meetme --- - -CREATE TABLE meetme ( - confno char(80) DEFAULT '0' NOT NULL, - pin char(20) NULL, - adminpin char(20) NULL, - members integer DEFAULT 0 NOT NULL, - PRIMARY KEY (confno) -); - diff --git a/contrib/scripts/messages-expire.pl b/contrib/scripts/messages-expire.pl deleted file mode 100644 index 993997899..000000000 --- a/contrib/scripts/messages-expire.pl +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/perl -# -# Script to expire voicemail after a specified number of days -# by Steve Creel -# - -# 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; - -# Age for unheard messages (Defaults to same age for all messages) -# Set to 0 to not delete unheard messages -$unheardage = $age; - - -# Delete all files older than $age and $unheardage -# (named msg????.??? to get the audio and txt files, -# but we don't delete greetings or the user's name) - -if($age==$unheardage) { - - # Save time by doing one find if we're treating everything the same - system('find '.$dir.'/'.$context.' -name msg????.??? -mtime +'.$age.' -exec rm {} \; -exec echo Deleted {} \;'); - -} else { - - # Find everything not in a folder called 'INBOX' and delete it after $age days - system('find '.$dir.'/'.$context.' -path \'*INBOX*\' -prune -o -name msg????.??? -mtime +'.$age.' -exec rm {} \; -exec echo Deleted {} \;'); - - # If unheardage is set to 0, we won't delete any unheard messages - if($unheardage > 0) { - - # Delete things that are in a folder called INBOX after $unheardage days - system('find '.$dir.'/'.$context.' -path \'*INBOX*\' -name msg????.??? -mtime +'.$unheardage.' -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 diff --git a/contrib/scripts/qview.pl b/contrib/scripts/qview.pl deleted file mode 100644 index 940e474f7..000000000 --- a/contrib/scripts/qview.pl +++ /dev/null @@ -1,100 +0,0 @@ -#!/usr/bin/perl -# -# Asterisk Queue Viewer -# Uses management interface to query call queues on a machine -# (C) 2003 David C. Troy -- dave@toad.net -# -# This program is free software, distributed under the terms of the -# GNU General Public License -# - -use IO::Socket; -use CGI qw(:standard); -use CGI::Carp qw/fatalsToBrowser/; - -$host = "asterisk.yourdomain.com"; -$port = 5038; -$user = "manager_user"; -$secret = "Manager_secret"; -$EOL = "\015\012"; -$BLANK = $EOL x 2; -$queue = param('queue'); - -$remote = IO::Socket::INET->new( - Proto => 'tcp', # protocol - PeerAddr=> $host, # Address of server - PeerPort=> $port, # port of server - Reuse => 1 - ) or die "$!"; - -$remote->autoflush(1); # Send immediately - -# Login and get our booty from Asterisk -$logres = send_cmd("Action: Login${EOL}Username: $user${EOL}Secret: $secret$BLANK"); -$qinfo = send_cmd("Action: queues$BLANK$EOL"); -$logres = send_cmd("Action: Logoff$BLANK"); -close $remote; # Close socket - -my %qcalls = map { /(\S+)\s+has (\d+) calls.*?\n\n/sg; } $qinfo; -my %qmax = map { /(\S+)\s+has \d+ calls \(max (\S+)\).*?\n\n/sg; } $qinfo; -my %qstrat = map { /(\S+)\s+has \d+ calls \(max \S+\) in (\S+) strategy.*?\n\n/sg; } $qinfo; -my %qmems = map { /(\S+)\s+has \d+ calls.*?Members:.*?\s{6}(.*?)\s{3}\S*?\s*?Callers/sg; } $qinfo; -my %qcallers = map { /(\S+)\s+has \d+ calls.*?([No ]*Callers.*?)\n\n/sg; } $qinfo; - -print header(); -print start_html(-head=>meta({-http_equiv=>'Refresh', -content=>'120'}), - -title=>"PBX Queue Viewer", - -style=>{'src'=>'/pbxinfo.css'}); -print ""; - -$col = 0; - -foreach $q (keys %qcalls) { - - $mems = $qmems{$q}; - $mems =~ s/ //g; - $mems =~ s/\n/
\n/g; - $callers = $qcallers{$q}; - $callers =~ s/ //g; - $callers =~ s/Callers:.*\n//g; - $callers =~ s/\n/
/g; - - print qq{ -}; - - print "" if $col; - $col = 0 if $col++; - -} - -print "
- - -
$q  $qcalls{$q} calls (max $qmax{$q}), $qstrat{$q} strategy
$mems$callers
"; - -print end_html(); - -exit(0); - -sub read_conn { - - my $buf=""; - while (<$remote>) { - last if $_ eq $EOL; - s/$EOL/\n/g; - $buf .= $_; - } - - return $buf -} - -sub send_cmd { - my $cmd = @_[0]; - - my $buf=""; - print $remote $cmd; - - $buf = read_conn(); - - return $buf; -} diff --git a/contrib/scripts/realtime_pgsql.sql b/contrib/scripts/realtime_pgsql.sql deleted file mode 100644 index 319c9e108..000000000 --- a/contrib/scripts/realtime_pgsql.sql +++ /dev/null @@ -1,142 +0,0 @@ -drop table extensions_conf; - -CREATE TABLE extensions_conf ( -id serial NOT NULL, -context character varying(20) DEFAULT '' NOT NULL, -exten character varying(20) DEFAULT '' NOT NULL, -priority smallint DEFAULT 0 NOT NULL, -app character varying(20) DEFAULT '' NOT NULL, -appdata character varying(128) -); - -drop table cdr; -CREATE TABLE cdr ( -calldate timestamp with time zone DEFAULT now() NOT NULL, -clid character varying(80) DEFAULT '' NOT NULL, -src character varying(80) DEFAULT '' NOT NULL, -dst character varying(80) DEFAULT '' NOT NULL, -dcontext character varying(80) DEFAULT '' NOT NULL, -channel character varying(80) DEFAULT '' NOT NULL, -dstchannel character varying(80) DEFAULT '' NOT NULL, -lastapp character varying(80) DEFAULT '' NOT NULL, -lastdata character varying(80) DEFAULT '' NOT NULL, -duration bigint DEFAULT 0::bigint NOT NULL, -billsec bigint DEFAULT 0::bigint NOT NULL, -disposition character varying(45) DEFAULT '' NOT NULL, -amaflags bigint DEFAULT 0::bigint NOT NULL, -accountcode character varying(20) DEFAULT '' NOT NULL, -uniqueid character varying(32) DEFAULT '' NOT NULL, -userfield character varying(255) DEFAULT '' NOT NULL -); - -drop table sip_conf; -CREATE TABLE sip_conf ( -id serial NOT NULL, -name character varying(80) DEFAULT '' NOT NULL, -accountcode character varying(20), -amaflags character varying(7), -callgroup character varying(10), -callerid character varying(80), -canreinvite character varying(3) DEFAULT 'yes', -context character varying(80), -defaultip character varying(15), -dtmfmode character varying(7), -fromuser character varying(80), -fromdomain character varying(80), -host character varying(31) DEFAULT '' NOT NULL, -insecure character varying(4), -"language" character varying(2), -mailbox character varying(50), -md5secret character varying(80), -nat character varying(5) DEFAULT 'no' NOT NULL, -permit character varying(95), -deny character varying(95), -mask character varying(95), -pickupgroup character varying(10), -port character varying(5) DEFAULT '' NOT NULL, -qualify character varying(3), -restrictcid character varying(1), -rtptimeout character varying(3), -rtpholdtimeout character varying(3), -secret character varying(80), -"type" character varying DEFAULT 'friend' NOT NULL, -username character varying(80) DEFAULT '' NOT NULL, -disallow character varying(100) DEFAULT 'all', -allow character varying(100) DEFAULT 'g729;ilbc;gsm;ulaw;alaw', -musiconhold character varying(100), -regseconds bigint DEFAULT 0::bigint NOT NULL, -ipaddr character varying(15) DEFAULT '' NOT NULL, -regexten character varying(80) DEFAULT '' NOT NULL, -cancallforward character varying(3) DEFAULT 'yes' -); - -drop table voicemail_users; -CREATE TABLE voicemail_users ( -id serial NOT NULL, -customer_id bigint DEFAULT (0)::bigint NOT NULL, -context character varying(50) DEFAULT '' NOT NULL, -mailbox bigint DEFAULT (0)::bigint NOT NULL, -"password" character varying(4) DEFAULT '0' NOT NULL, -fullname character varying(50) DEFAULT '' NOT NULL, -email character varying(50) DEFAULT '' NOT NULL, -pager character varying(50) DEFAULT '' NOT NULL, -stamp timestamp(6) without time zone NOT NULL -); - -drop table queue_table; -CREATE TABLE queue_table ( -name varchar(128), -musiconhold varchar(128), -announce varchar(128), -context varchar(128), -timeout int8, -monitor_join bool, -monitor_format varchar(128), -queue_youarenext varchar(128), -queue_thereare varchar(128), -queue_callswaiting varchar(128), -queue_holdtime varchar(128), -queue_minutes varchar(128), -queue_seconds varchar(128), -queue_lessthan varchar(128), -queue_thankyou varchar(128), -queue_reporthold varchar(128), -announce_frequency int8, -announce_round_seconds int8, -announce_holdtime varchar(128), -retry int8, -wrapuptime int8, -maxlen int8, -servicelevel int8, -strategy varchar(128), -joinempty varchar(128), -leavewhenempty varchar(128), -eventmemberstatus bool, -eventwhencalled bool, -reportholdtime bool, -memberdelay int8, -weight int8, -timeoutrestart bool, -setinterfacevar bool, -PRIMARY KEY (name) -) WITHOUT OIDS; -ALTER TABLE queue_table OWNER TO asterisk; - -drop table queue_member_table; -CREATE TABLE queue_member_table -( -queue_name varchar(128), -interface varchar(128), -penalty int8, -PRIMARY KEY (queue_name, interface) -) WITHOUT OIDS; - -GRANT ALL ON TABLE cdr TO asterisk; -GRANT ALL ON TABLE extensions_conf TO asterisk; -GRANT ALL ON TABLE sip_conf TO asterisk; -GRANT ALL ON TABLE voicemail_users TO asterisk; -GRANT ALL ON TABLE queue_member_table TO asterisk; -GRANT ALL ON TABLE queue_table TO asterisk; - - - diff --git a/contrib/scripts/retrieve_extensions_from_mysql.pl b/contrib/scripts/retrieve_extensions_from_mysql.pl deleted file mode 100644 index ca195cfe5..000000000 --- a/contrib/scripts/retrieve_extensions_from_mysql.pl +++ /dev/null @@ -1,113 +0,0 @@ -#!/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; - diff --git a/contrib/scripts/retrieve_extensions_from_sql.pl b/contrib/scripts/retrieve_extensions_from_sql.pl deleted file mode 100644 index cf17d0351..000000000 --- a/contrib/scripts/retrieve_extensions_from_sql.pl +++ /dev/null @@ -1,158 +0,0 @@ -#!/usr/bin/perl -Tw -# Author: Peter Nixon -# Date: April 2004 -# Copy Policy: GNU Public Licence Version 2 or later -# URL: http://www.peternixon.net/code/ -# Supported: PostgreSQL, Oracle, MySQL -# Copyright: 2004 Peter Nixon -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# $Id$ -# -# Use these commands to create the appropriate SQL tables -# If flags is 1 then the record is not included in the output extensions file -# -#CREATE TABLE extensions ( -# context VARCHAR(20) DEFAULT 'default' NOT NULL, -# extension VARCHAR(20) NOT NULL, -# priority INTEGER DEFAULT '1' NOT NULL, -# application VARCHAR(20) NOT NULL, -# args VARCHAR(50), -# descr TEXT, -# flags BOOLEAN DEFAULT '0' NOT NULL, -# PRIMARY KEY(context, extension, priority) -#); - -#CREATE TABLE globals ( -# variable VARCHAR(20) NOT NULL, -# value VARCHAR(50) NOT NULL, -# PRIMARY KEY(variable, value) -#); - -use strict; # Make sure we write decent perl code - -require DBI; # We need database drivers for this thing to work - -################### BEGIN OF CONFIGURATION #################### - -my $table_name = "extensions"; # name of the extensions table -my $global_table_name = "globals"; # name of the globals table -my $extensions_conf = "/etc/asterisk/extensions.conf"; # path to extensions.conf -# WARNING: this file will be substituted by the output of this program -my $dbbrand = "Pg"; # Hint: "mysql" or any other Perl DBI driver. -my $hostname = "localhost"; # The SQL server's hostname or IP -my $database = "peter"; # the name of the database our tables are kept -my $username = "peter"; # username to connect to the database -my $password = ""; # password to connect to the database -my $verbose = 1; # Verbosity Level (0 - 2) - -################### END OF CONFIGURATION ####################### - -# You should not need to edit anything below here -my $dbh; - -sub db_connect { - if ($verbose > 1) { print "DEBUG: Connecting to Database Host: $hostname\n" } - if ($hostname eq 'localhost') { - if ($verbose > 1) { print "DEBUG: SQL server is on localhost so using UNIX socket instead of network socket.\n" } - $dbh = DBI->connect("DBI:$dbbrand:dbname=$database", "$username", "$password") - or die "Couldn't connect to database: " . DBI->errstr; - } - else { - $dbh = DBI->connect("DBI:$dbbrand:dbname=$database;host=$hostname", "$username", "$password") - or die "Couldn't connect to database: " . DBI->errstr; - } -} - -sub db_disconnect { - if ($verbose > 1) { print "DEBUG: Disconnecting from Database Host: $hostname\n" } - $dbh->disconnect - or warn "Disconnection failed: $DBI::errstr\n"; -} - -sub get_globals { - if ($verbose > 0) { print "Checking Database for [global] variables\n"; } - my $sth = $dbh->prepare("SELECT variable, value FROM $global_table_name ORDER BY variable") - or die "Couldn't prepare statement: " . $dbh->errstr; - - $sth->execute() # Execute the query - or die "Couldn't execute SELECT statement: " . $sth->errstr; - - if ($sth->rows > 0) { - print EXTEN "[globals]\n"; - while (my @global = $sth->fetchrow_array()) { - print EXTEN "$global[0] = $global[1]\n"; - } - print EXTEN "\n"; - } else { - print "WARNING: You have no global variables set\n"; - } - $sth->finish; -} - -sub get_contexts { - if ($verbose > 0) { print "Checking Database for contexts\n"; } - my $sth = $dbh->prepare("SELECT context FROM $table_name GROUP BY context") - or die "Couldn't prepare statement: " . $dbh->errstr; - - $sth->execute() # Execute the query - or die "Couldn't execute SELECT statement: " . $sth->errstr; - - if ($sth->rows > 0) { - while (my @context = $sth->fetchrow_array()) { - print EXTEN "[$context[0]]\n"; - &get_extensions($context[0]); - print EXTEN "\n"; - } - print EXTEN "\n"; - } else { - print "WARNING: You have no contexts defined in the $table_name table\n"; - } - $sth->finish; -} - -sub get_extensions { - my $context = $_[0]; my @extension; - if ($verbose > 0) { print " Checking Database for [$context] extensions\n"; } - my $sth = $dbh->prepare("SELECT extension, priority, application, args, descr FROM $table_name WHERE context='$context' AND flags = '0' ORDER BY extension, priority") - or die "Couldn't prepare statement: " . $dbh->errstr; - - $sth->execute() # Execute the query - or die "Couldn't execute SELECT statement: " . $sth->errstr; - - if ($sth->rows > 0) { - while (@extension = $sth->fetchrow_array()) { - print EXTEN "exten => $extension[0],$extension[1],$extension[2]"; - print EXTEN "($extension[3])" if defined $extension[3]; - print EXTEN " ; $extension[4]" if defined $extension[4]; - print EXTEN "\n"; - } - } else { - print "WARNING: You have no extensions for [$context]\n"; - } - $sth->finish; -} - - -sub main { - open EXTEN, ">$extensions_conf" || die "Cannot create/overwrite extensions file: $extensions_conf\n"; - &db_connect; - &get_globals; - &get_contexts; - &db_disconnect; - close EXTEN; # Close the file handle - if ($verbose > 0) { print "New $extensions_conf successfully written.\n"; } - return 1; -} - - -exit &main(); diff --git a/contrib/scripts/retrieve_sip_conf_from_mysql.pl b/contrib/scripts/retrieve_sip_conf_from_mysql.pl deleted file mode 100644 index 03395a125..000000000 --- a/contrib/scripts/retrieve_sip_conf_from_mysql.pl +++ /dev/null @@ -1,93 +0,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; - diff --git a/contrib/scripts/safe_asterisk b/contrib/scripts/safe_asterisk deleted file mode 100644 index 3884ef4df..000000000 --- a/contrib/scripts/safe_asterisk +++ /dev/null @@ -1,178 +0,0 @@ -#!/bin/sh -# vim:textwidth=80:tabstop=4:shiftwidth=4:smartindent:autoindent - -CLIARGS="$*" # Grab any args passed to safe_asterisk -TTY=9 # TTY (if you want one) for Asterisk to run on -CONSOLE=yes # Whether or not you want a console -#NOTIFY=ben@alkaloid.net # Who to notify about crashes -#EXEC=/path/to/somescript # Run this command if Asterisk crashes -MACHINE=`hostname` # To specify which machine has crashed when getting the mail -DUMPDROP=/tmp -SLEEPSECS=4 -ASTSBINDIR=__ASTERISK_SBIN_DIR__ -ASTPIDFILE=__ASTERISK_VARRUN_DIR__/asterisk.pid - -# comment this line out to have this script _not_ kill all mpg123 processes when -# asterisk exits -KILLALLMPG123=1 - -# run asterisk with this priority -PRIORITY=0 - -# set system filemax on supported OSes if this variable is set -# SYSMAXFILES=262144 - -# set max files open with ulimit. On linux systems, this will be automatically -# set to the system's maximum files open devided by two, if not set here. -# MAXFILES=32768 - -# Check if Asterisk is already running. If it is, then bug out, because -# starting safe_asterisk when Asterisk is running is very bad. -VERSION=`${ASTSBINDIR}/asterisk -rx 'core show version'` -if [ "`echo $VERSION | cut -c 1-8`" = "Asterisk" ]; then - echo "Asterisk is already running. $0 will exit now." - exit 1 -fi - -# since we're going to change priority and open files limits, we need to be -# root. if running asterisk as other users, pass that to asterisk on the command -# line. -# if we're not root, fall back to standard everything. -if [ `id -u` != 0 ] -then - echo "Oops. I'm not root. Falling back to standard prio and file max." >&2 - echo "This is NOT suitable for large systems." >&2 - PRIORITY=0 -else - if `echo $OSTYPE | grep linux 2>&1 > /dev/null ` - then - # maximum number of open files is set to the system maximum divided by two if - # MAXFILES is not set. - if [ "$MAXFILES" = "" ] - then - # just check if file-max is readable - if [ -r /proc/sys/fs/file-max ] - then - MAXFILES=$(( `cat /proc/sys/fs/file-max` / 2 )) - fi - fi - SYSCTL_MAXFILES="fs.file-max" - elif `echo $OSTYPE | grep darwin 2>&1 > /dev/null ` - then - SYSCTL_MAXFILES="kern.maxfiles" - fi - - - if [ "$SYSMAXFILES" != "" ] - then - if [ "$SYSCTL_MAXFILES" != "" ] - then - sysctl -w $SYSCTL_MAXFILES=$SYSMAXFILES - fi - fi - - # set the process's filemax to whatever set above - ulimit -n $MAXFILES - -fi - -# -# Let Asterisk dump core -# -ulimit -c unlimited - -# -# Don't fork when running "safely" -# -ASTARGS="" -if [ "$TTY" != "" ]; then - if [ -c /dev/tty${TTY} ]; then - TTY=tty${TTY} - elif [ -c /dev/vc/${TTY} ]; then - TTY=vc/${TTY} - else - echo "Cannot find your TTY (${TTY})" >&2 - exit 1 - fi - ASTARGS="${ASTARGS} -vvvg" - if [ "$CONSOLE" != "no" ]; then - ASTARGS="${ASTARGS} -c" - fi -fi -if [ ! -w ${DUMPDROP} ]; then - echo "Cannot write to ${DUMPDROP}" >&2 - exit 1 -fi - -# -# Don't die if stdout/stderr can't be written to -# -trap '' PIPE - -# -# Run scripts to set any environment variables or do any other system-specific setup needed -# - -if [ -d /etc/asterisk/startup.d ]; then - for script in /etc/asterisk/startup.d/*.sh; do - if [ -x ${script} ]; then - source ${script} - fi - done -fi - -run_asterisk() -{ - while :; do - - if [ "$TTY" != "" ]; then - cd /tmp - stty sane < /dev/${TTY} - nice -n $PRIORITY ${ASTSBINDIR}/asterisk -f ${CLIARGS} ${ASTARGS} >& /dev/${TTY} < /dev/${TTY} - else - cd /tmp - nice -n $PRIORITY ${ASTSBINDIR}/asterisk -f ${CLIARGS} ${ASTARGS} - fi - EXITSTATUS=$? - echo "Asterisk ended with exit status $EXITSTATUS" - if [ "$EXITSTATUS" = "0" ]; then - # Properly shutdown.... - echo "Asterisk shutdown normally." - exit 0 - elif [ $EXITSTATUS -gt 128 ]; then - let EXITSIGNAL=EXITSTATUS-128 - echo "Asterisk exited on signal $EXITSIGNAL." - if [ "$NOTIFY" != "" ]; then - echo "Asterisk on $MACHINE exited on signal $EXITSIGNAL. Might want to take a peek." | \ - mail -s "Asterisk Died" $NOTIFY - fi - if [ "$EXEC" != "" ]; then - $EXEC - fi - - PID=`cat ${ASTPIDFILE}` - if [ -f /tmp/core.${PID} ]; then - mv /tmp/core.${PID} ${DUMPDROP}/core.`hostname`-`date -Iseconds` & - elif [ -f /tmp/core ]; then - mv /tmp/core ${DUMPDROP}/core.`hostname`-`date -Iseconds` & - fi - else - echo "Asterisk died with code $EXITSTATUS." - - PID=`cat ${ASTPIDFILE}` - if [ -f /tmp/core.${PID} ]; then - mv /tmp/core.${PID} ${DUMPDROP}/core.`hostname`-`date -Iseconds` & - elif [ -f /tmp/core ]; then - mv /tmp/core ${DUMPDROP}/core.`hostname`-`date -Iseconds` & - fi - fi - echo "Automatically restarting Asterisk." - sleep $SLEEPSECS - if [ $KILLALLMPG123 ] - then - killall -9 mpg123 - fi - done -} - -run_asterisk & diff --git a/contrib/scripts/safe_asterisk.8 b/contrib/scripts/safe_asterisk.8 deleted file mode 100644 index ebd95142a..000000000 --- a/contrib/scripts/safe_asterisk.8 +++ /dev/null @@ -1,69 +0,0 @@ -.TH SAFE_ASTERISK 8 "Jun 30th, 2005" "Asterisk" "Linux Programmer's Manual" -.SH NAME -.B safe_asterisk -\(em A wrapper to run the asterisk executable in a loop -.SH SYNOPSIS -.PP -.B safe_asterisk -.I [ asterisk_params ] - -.SH DESCRIPTION -.B safe_asterisk -is a script that runs asterisk in a loop, which can be useful if you -fear asterisk may crash. - -The script does not run in the background like a standard service. Rather, -it runs in its own linux virtual console (9, by default). -It also uses the option '-c' of asterisk(8) to avoid detaching asterisk -from that terminal. - -safe_asterisk also runs asterisk with unlimited core file size, and thus -asterisk will dump core in case of a crash. - -To get a "picture" of console 9, from another terminal (e.g: from a -remote shell session) you can use: - - screendump 9 - -The init script of the Debian package should be able to run safe_asterisk -as the asterisk service, if so configured. See coments in -/etc/default/asterisk - -.SH FILES -.B /tmp -.RS -safe_asterisk runs in that directory, rather than in / as usual. -.RE - -.B /tmp/core -.RS -If core files were generated there, they may be -.RE - -.B /etc/asterisk/startup.d -.RS -Files in this directory will be 'source'd by the safe_asterisk script before -it starts Asterisk proper, allowing them to set additional environment variables -or run any other steps that are needed for your system. -.RE - -.SH BUGS -While showing the output on a console is useful, using screen(1) as -the terminal may be better. - -The script does not read configuration from standard location under /etc - -It uses fixed locations under /tmp , and thus may be exposed to a -symlink attacks. - -.SH SEE ALSO -asterisk(8), screendump(9) - -.SH "AUTHOR" -This manual page was written by Tzafrir Cohen -Permission is granted to copy, distribute and/or modify this document under -the terms of the GNU General Public License, Version 2 any -later version published by the Free Software Foundation. - -On Debian systems, the complete text of the GNU General Public -License can be found in /usr/share/common-licenses/GPL. diff --git a/contrib/scripts/safe_asterisk_restart b/contrib/scripts/safe_asterisk_restart deleted file mode 100644 index 81783149a..000000000 --- a/contrib/scripts/safe_asterisk_restart +++ /dev/null @@ -1,110 +0,0 @@ -#!/bin/bash -# vim:textwidth=80:tabstop=4:shiftwidth=4:smartindent -# -# this scripts prompts the user thrice, then tells asterisk to please shut down, -# then kills asterisk and related processes with SIGTERM, then kills asterisk -# and related processes with SIGKILL, and then starts asterisk with -# safe_asterisk. Three arguments are currently supported, --no-countdown, -# --no-prompt and --no-stop-now-first - -LOGFILE=/var/log/asterisk/safe_asterisk_restart.log -ASTERISK=/usr/sbin/asterisk -SAFE_ASTERISK=/usr/sbin/safe_asterisk - -DELAY=1 # Seconds between steps in countdown -COUNTDOWN_FROM=5 # Steps to count down -DO_COUNTDOWN=1 # Should I do a countdown before restarting asterisk? -DO_PROMPT=1 # Should I prompt the user? -TRY_STOP_NOW_FIRST=1 # Attempt a 'stop now' before killing processes. Note - # that this might make this script hang if asterisk - # can't respond to the command. - -# processes to kill. Please list all AGI scripts here as well as the asterisk -# processes, since asterisk may leave them unkilled. -PROCVICTIMS="safe_asterisk asterisk mpg123" - -# helper functions -# die ["string to print"] -function die { - if [[ "$1" != "" ]]; then - echo $1 - else - echo "ok. no harm done..." - fi - exit -} - -# docmd "string to print" "cmd" -function docmd { - printf "$1..." - `$2 >> $LOGFILE 2>&1` - RETCODE=$? - sleep $DELAY - if [[ "$RETCODE" == "0" ]]; then - echo " OK" - else - echo " FAILED" - fi -} - -# prompt "string" "positive answer" -function prompt { - printf "$1" - read answer - if [[ "$answer" != "$2" ]]; then - die - fi -} - -# countdown secs -function countdown { - echo -n "$1 " - if [[ $1 > 0 ]]; then - sleep 1 - countdown $[ $1 - 1 ] - else - echo "boom!" - fi -} - -# am I really root? -if [[ "$UID" != "0" ]]; then - echo "Sorry, only root can do this." >&2 - exit; -fi - -echo "`date`: $0 invoked" >> $LOGFILE - -# bash -for i -do - if [[ "$i" == "--no-countdown" ]] - then - unset DO_COUNTDOWN - fi - if [[ "$i" == "--no-prompt" ]] - then - unset DO_PROMPT - fi - if [[ "$i" == "--no-stop-now-first" ]] - then - unset TRY_STOP_NOW_FIRST - fi -done - -[[ $DO_PROMPT ]] && prompt "Are you sure you want to restart asterisk? (yes/no)? " "yes" -[[ $DO_PROMPT ]] && prompt "Really sure? (yes/no)? " "yes" -[[ $DO_PROMPT ]] && prompt "Absolutely positive? (YES/no)? " "YES" - -[[ $DO_COUNTDOWN ]] && echo "OK, I'll do it, but if you're not sure about this, press ctrl+c now." -[[ $DO_COUNTDOWN ]] && countdown $COUNTDOWN_FROM - -# doing the dirty work -[[ $TRY_STOP_NOW_FIRST ]] && docmd "Asking asterisk kindly to shutdown" "$ASTERISK -rx 'stop now'" -docmd "Sending asterisk processes the TERM signal" "killall -15 $PROCVICTIMS" -docmd "Sending asterisk processes KILL signal" "killall -9 $PROCVICTIMS" -docmd "Starting safe_asterisk" "$SAFE_ASTERISK" -for i in $PROCVICTIMS -do - ps axf | grep -w $i | grep -v grep -done diff --git a/contrib/scripts/sip-friends.sql b/contrib/scripts/sip-friends.sql deleted file mode 100644 index d76db7f93..000000000 --- a/contrib/scripts/sip-friends.sql +++ /dev/null @@ -1,54 +0,0 @@ -# -# Table structure for table `sipfriends` -# - -CREATE TABLE `sipfriends` ( - `name` varchar(40) NOT NULL default '', - `type` varchar(10) NOT NULL default '', - `username` varchar(40), - `fromuser` varchar(40), - `fromdomain` varchar(40), - `secret` varchar(40), - `md5secret` varchar(40), - `auth` varchar(10), - `mailbox` varchar(20), - `subscribemwi` varchar(10), -- yes/no - `vmexten` varchar(20), - `callerid` varchar(40), - `cid_number` varchar(40), - `callingpres` varchar(20), - `usereqphone` varchar(10), - `language` varchar(10), - `incominglimit` varchar(10), - `context` varchar(40) NOT NULL default '', - `subscribecontext` varchar(40), - `amaflags` varchar(20), - `accountcode` varchar(20), - `musicclass` varchar(20), - `mohsuggest` varchar(20), - `allowtransfer` varchar(20), - `callgroup` varchar(20), - `pickupgroup` varchar(20), - `autoframing` varchar(10), -- yes/no - `disallow` varchar(20) default 'all', - `allow` varchar(20), - `maxcallbitrate` varchar(15), - `host` varchar(40) default 'dynamic', - `outboundproxy` varchar(40), - `ipaddr` varchar(20) NOT NULL default '', - `defaultip` varchar(20), - `port` int(6) NOT NULL default '0', - `fullcontact` varchar(40), - `insecure` varchar(20), - `qualify` varchar(15), - `regseconds` int(11) NOT NULL default '0', - `regexten` varchar(20), - `regserver` varchar(20), - `rtptimeout` varchar(15), - `rtpholdtimeout` varchar(15), - `rtpkeepalive` varchar(15), - `setvar` varchar(200), - PRIMARY KEY (`name`), - INDEX host (host, port), - INDEX ipaddr (ipaddr, port), -) TYPE=MyISAM; diff --git a/contrib/scripts/vmail.cgi b/contrib/scripts/vmail.cgi deleted file mode 100644 index de51a4dc7..000000000 --- a/contrib/scripts/vmail.cgi +++ /dev/null @@ -1,1140 +0,0 @@ -#!/usr/bin/perl -# -# Web based Voicemail for Asterisk -# -# Copyright (C) 2002, Linux Support Services, Inc. -# -# Distributed under the terms of the GNU General Public License -# -# Written by Mark Spencer -# -# (icky, I know.... if you know better perl please help!) -# -# -# Synchronization added by GDS Partners (www.gdspartners.com) -# Stojan Sljivic (stojan.sljivic@gdspartners.com) -# -use CGI qw/:standard/; -use Carp::Heavy; -use CGI::Carp qw(fatalsToBrowser); -use DBI; -use Fcntl qw ( O_WRONLY O_CREAT O_EXCL ); -use Time::HiRes qw ( usleep ); - -$context=""; # Define here your by default context (so you dont need to put voicemail@context in the login) - -@validfolders = ( "INBOX", "Old", "Work", "Family", "Friends", "Cust1", "Cust2", "Cust3", "Cust4", "Cust5" ); - -%formats = ( - "wav" => { - name => "Uncompressed WAV", - mime => "audio/x-wav", - pref => 1 - }, - "WAV" => { - name => "GSM Compressed WAV", - mime => "audio/x-wav", - pref => 2 - }, - "gsm" => { - name => "Raw GSM Audio", - mime => "audio/x-gsm", - pref => 3 - } -); - -$astpath = "/_asterisk"; - -$stdcontainerstart = "
\n"; -$footer = "
The Asterisk Open Source PBX Copyright 2004-2008, Digium, Inc."; -$stdcontainerend = "
$footer
\n"; - -sub lock_path($) { - - my($path) = @_; - my $rand; - my $rfile; - my $start; - my $res; - - $rand = rand 99999999; - $rfile = "$path/.lock-$rand"; - - sysopen(RFILE, $rfile, O_WRONLY | O_CREAT | O_EXCL, 0666) or return -1; - close(RFILE); - - $res = link($rfile, "$path/.lock"); - $start = time; - if ($res == 0) { - while (($res == 0) && (time - $start <= 5)) { - $res = link($rfile, "$path/.lock"); - usleep(1); - } - } - unlink($rfile); - - if ($res == 0) { - return -1; - } else { - return 0; - } -} - -sub unlock_path($) { - - my($path) = @_; - - unlink("$path/.lock"); -} - -sub untaint($) { - - my($data) = @_; - - if ($data =~ /^([-\@\w.]+)$/) { - $data = $1; - } else { - die "Security violation."; - } - - return $data; -} - -sub login_screen($) { - print header; - my ($message) = @_; - print <<_EOH; - -Asterisk Web-Voicemail - -$stdcontainerstart -
- - - - - - - - - -
Comedian Mail Login
$message
Mailbox:
Password:
-
-$stdcontainerend -\n -_EOH - -} - -sub check_login($$) -{ - local ($filename, $startcat) = @_; - local ($mbox, $context) = split(/\@/, param('mailbox')); - local $pass = param('password'); - local $category = $startcat; - local @fields; - local $tmp; - local (*VMAIL); - if (!$category) { - $category = "general"; - } - if (!$context) { - $context = param('context'); - } - if (!$context) { - $context = "default"; - } - if (!$filename) { - $filename = "/etc/asterisk/voicemail.conf"; - } -# print header; -# print "Including

$filename

while in

$category

...\n"; - open(VMAIL, "<$filename") || die("Bleh, no $filename"); - while() { - chomp; - if (/include\s\"([^\"]+)\"$/) { - ($tmp, $category) = &check_login("/etc/asterisk/$1", $category); - if (length($tmp)) { -# print "Got '$tmp'\n"; - return ($tmp, $category); - } - } elsif (/\[(.*)\]/) { - $category = $1; - } elsif ($category eq "general") { - if (/([^\s]+)\s*\=\s*(.*)/) { - if ($1 eq "dbname") { - $dbname = $2; - } elsif ($1 eq "dbpass") { - $dbpass = $2; - } elsif ($1 eq "dbhost") { - $dbhost = $2; - } elsif ($1 eq "dbuser") { - $dbuser = $2; - } - } - if ($dbname and $dbpass and $dbhost and $dbuser) { - - # db variables are present. Use db for authentication. - my $dbh = DBI->connect("DBI:mysql:$dbname:$dbhost",$dbuser,$dbpass); - my $sth = $dbh->prepare(qq{select fullname,context from voicemail where mailbox='$mbox' and password='$pass' and context='$context'}); - $sth->execute(); - if (($fullname, $category) = $sth->fetchrow_array()) { - return ($fullname ? $fullname : "Extension $mbox in $context",$category); - } - } - } elsif (($category ne "general") && ($category ne "zonemessages")) { - if (/([^\s]+)\s*\=\>?\s*(.*)/) { - @fields = split(/\,\s*/, $2); -# print "

Mailbox is $1\n"; - if (($mbox eq $1) && (($pass eq $fields[0]) || ("-${pass}" eq $fields[0])) && ($context eq $category)) { - return ($fields[1] ? $fields[1] : "Extension $mbox in $context", $category); - } - } - } - } - close(VMAIL); - return check_login_users(); -} - -sub check_login_users { - my ($mbox, $context) = split(/\@/, param('mailbox')); - my $pass = param('password'); - my ($found, $fullname) = (0, ""); - open VMAIL, ") { - chomp; - if (m/\[(.*)\]/) { - if ($1 eq $mbox) { - $found = 1; - } elsif ($found == 2) { - close VMAIL; - return (($fullname ? $fullname : "Extension $mbox in $context"), $context); - } else { - $found = 0; - } - } elsif ($found) { - my ($var, $value) = split /\s*=\s*/, $_, 2; - if ($var eq 'vmsecret' and $value eq $pass) { - $found = 2; - } elsif ($var eq 'fullname') { - $fullname = $value; - if ($found == 2) { - close VMAIL; - return ($fullname, $context); - } - } - } - } - close VMAIL; - return ("", ""); -} - -sub validmailbox($$$$) -{ - local ($context, $mbox, $filename, $startcat) = @_; - local $category = $startcat; - local @fields; - local (*VMAIL); - if (!$context) { - $context = param('context'); - } - if (!$context) { - $context = "default"; - } - if (!$filename) { - $filename = "/etc/asterisk/voicemail.conf"; - } - if (!$category) { - $category = "general"; - } - open(VMAIL, "<$filename") || die("Bleh, no $filename"); - while () { - chomp; - if (/include\s\"([^\"]+)\"$/) { - ($tmp, $category) = &validmailbox($mbox, $context, "/etc/asterisk/$1"); - if ($tmp) { - return ($tmp, $category); - } - } elsif (/\[(.*)\]/) { - $category = $1; - } elsif ($category eq "general") { - if (/([^\s]+)\s*\=\s*(.*)/) { - if ($1 eq "dbname") { - $dbname = $2; - } elsif ($1 eq "dbpass") { - $dbpass = $2; - } elsif ($1 eq "dbhost") { - $dbhost = $2; - } elsif ($1 eq "dbuser") { - $dbuser = $2; - } - } - if ($dbname and $dbpass and $dbhost and $dbuser) { - - # db variables are present. Use db for authentication. - my $dbh = DBI->connect("DBI:mysql:$dbname:$dbhost",$dbuser,$dbpass); - my $sth = $dbh->prepare(qq{select fullname,context from voicemail where mailbox='$mbox' and password='$pass' and context='$context'}); - $sth->execute(); - if (($fullname, $context) = $sth->fetchrow_array()) { - return ($fullname ? $fullname : "unknown", $category); - } - } - } elsif (($category ne "general") && ($category ne "zonemessages") && ($category eq $context)) { - if (/([^\s]+)\s*\=\>?\s*(.*)/) { - @fields = split(/\,\s*/, $2); - if (($mbox eq $1) && ($context eq $category)) { - return ($fields[2] ? $fields[2] : "unknown", $category); - } - } - } - } - return ("", $category); -} - -sub mailbox_options() -{ - local($context, $current, $filename, $category) = @_; - local (*VMAIL); - local $tmp2; - local $tmp; - if (!$filename) { - $filename = "/etc/asterisk/voicemail.conf"; - } - if (!$category) { - $category = "general"; - } -# print header; -# print "Including

$filename

while in

$category

...\n"; - open(VMAIL, "<$filename") || die("Bleh, no voicemail.conf"); - while() { - chomp; - s/\;.*$//; - if (/include\s\"([^\"]+)\"$/) { - ($tmp2, $category) = &mailbox_options($context, $current, "/etc/asterisk/$1", $category); -# print "Got '$tmp2'...\n"; - $tmp .= $tmp2; - } elsif (/\[(.*)\]/) { - $category = $1; - } elsif ($category eq "general") { - if (/([^\s]+)\s*\=\s*(.*)/) { - if ($1 eq "dbname") { - $dbname = $2; - } elsif ($1 eq "dbpass") { - $dbpass = $2; - } elsif ($1 eq "dbhost") { - $dbhost = $2; - } elsif ($1 eq "dbuser") { - $dbuser = $2; - } - } - if ($dbname and $dbpass and $dbhost and $dbuser) { - - # db variables are present. Use db for authentication. - my $dbh = DBI->connect("DBI:mysql:$dbname:$dbhost",$dbuser,$dbpass); - my $sth = $dbh->prepare(qq{select mailbox,fullname,context from voicemail where context='$context' order by mailbox}); - $sth->execute(); - while (($mailbox, $fullname, $category) = $sth->fetchrow_array()) { - $text = $mailbox; - if ($fullname) { - $text .= " (".$fullname.")"; - } - if ($mailbox eq $current) { - $tmp .= "\n"; - } else { - $tmp .= "\n"; - } - } - return ($tmp, $category); - } - } elsif (($category ne "general") && ($category ne "zonemessages")) { - if (/([^\s]+)\s*\=\>?\s*(.*)/) { - @fields = split(/\,\s*/, $2); - $text = "$1"; - if ($fields[1]) { - $text .= " ($fields[1])"; - } - if ($1 eq $current) { - $tmp .= "\n"; - } else { - $tmp .= "\n"; - } - - } - } - } - close(VMAIL); - return ($tmp, $category); -} - -sub mailbox_list() -{ - local ($name, $context, $current) = @_; - local $tmp; - local $text; - local $tmp; - local $opts; - if (!$context) { - $context = "default"; - } - $tmp = "\n"; - -} - -sub msgcount() -{ - my ($context, $mailbox, $folder) = @_; - my $path = "/var/spool/asterisk/voicemail/$context/$mailbox/$folder"; - if (opendir(DIR, $path)) { - my @msgs = grep(/^msg....\.txt$/, readdir(DIR)); - closedir(DIR); - return sprintf "%d", $#msgs + 1; - } - return "0"; -} - -sub msgcountstr() -{ - my ($context, $mailbox, $folder) = @_; - my $count = &msgcount($context, $mailbox, $folder); - if ($count > 1) { - "$count messages"; - } elsif ($count > 0) { - "$count message"; - } else { - "no messages"; - } -} -sub messages() -{ - my ($context, $mailbox, $folder) = @_; - my $path = "/var/spool/asterisk/voicemail/$context/$mailbox/$folder"; - if (opendir(DIR, $path)) { - my @msgs = sort grep(/^msg....\.txt$/, readdir(DIR)); - closedir(DIR); - return map { s/^msg(....)\.txt$/$1/; $_ } @msgs; - } - return (); -} - -sub getcookie() -{ - my ($var) = @_; - return cookie($var); -} - -sub makecookie() -{ - my ($format) = @_; - cookie(-name => "format", -value =>["$format"], -expires=>"+1y"); -} - -sub getfields() -{ - my ($context, $mailbox, $folder, $msg) = @_; - my $fields; - if (open(MSG, ") { - s/\#.*$//g; - if (/^(\w+)\s*\=\s*(.*)$/) { - $fields->{$1} = $2; - } - } - close(MSG); - $fields->{'msgid'} = $msg; - } else { print "
Unable to open '$msg' in '$mailbox', '$folder'\n"; } - $fields; -} - -sub message_prefs() -{ - my ($nextaction, $msgid) = @_; - my $folder = param('folder'); - my $mbox = param('mailbox'); - my $context = param('context'); - my $passwd = param('password'); - my $format = param('format'); - if (!$format) { - $format = &getcookie('format'); - } - print header; - print <<_EOH; - -Asterisk Web-Voicemail: Preferences - -$stdcontainerstart -
- - - -_EOH - -foreach $fmt (sort { $formats{$a}->{'pref'} <=> $formats{$b}->{'pref'} } keys %formats) { - my $clicked = "checked" if $fmt eq $format; - print "\n"; -} - -print <<_EOH; - -
Web Voicemail Preferences
Preferred Audio Format:
 $formats{$fmt}->{name}
- - - - - - -$stdcontainerend -\n -_EOH - -} - -sub message_play() -{ - my ($message, $msgid) = @_; - my $folder = param('folder'); - my ($mbox, $context) = split(/\@/, param('mailbox')); - my $passwd = param('password'); - my $format = param('format'); - - my $fields; - if (!$context) { - $context = param('context'); - } - if (!$context) { - $context = "default"; - } - - my $folders = &folder_list('newfolder', $context, $mbox, $folder); - my $mailboxes = &mailbox_list('forwardto', $context, $mbox); - if (!$format) { - $format = &getcookie('format'); - } - if (!$format) { - &message_prefs("play", $msgid); - } else { - print header(-cookie => &makecookie($format)); - $fields = &getfields($context, $mbox, $folder, $msgid); - if (!$fields) { - print "
Bah!\n"; - return; - } - my $duration = $fields->{'duration'}; - if ($duration) { - $duration = sprintf "%d:%02d", $duration/60, $duration % 60; - } else { - $duration = "Unknown"; - } - print <<_EOH; - -Asterisk Web-Voicemail: $folder Message $msgid - -$stdcontainerstart - - - -_EOH - - print <<_EOH; - -
$folder Message $msgid
- - - \n - \n - \n - \n - \n - \n - \n - \n - -
$folder $msgid
Message:$msgid
Mailbox:$mbox\@$context
Folder:$folder
From:$fields->{callerid}
Duration:$duration
Original Date:$fields->{origdate}
Original Mailbox:$fields->{origmailbox}
Caller Channel:$fields->{callerchan}
-   -   -   - $mailboxes  - - $folders  - - -
- -
-
- - - - - -$stdcontainerend -\n -_EOH - } -} - -sub message_audio() -{ - my ($forcedownload) = @_; - my $folder = &untaint(param('folder')); - my $msgid = &untaint(param('msgid')); - my $mailbox = &untaint(param('mailbox')); - my $context = &untaint(param('context')); - my $format = param('format'); - if (!$format) { - $format = &getcookie('format'); - } - &untaint($format); - - my $path = "/var/spool/asterisk/voicemail/$context/$mailbox/$folder/msg${msgid}.$format"; - - $msgid =~ /^\d\d\d\d$/ || die("Msgid Liar ($msgid)!"); - grep(/^${format}$/, keys %formats) || die("Format Liar ($format)!"); - - # Mailbox and folder are already verified - if (open(AUDIO, "<$path")) { - $size = -s $path; - $|=1; - if ($forcedownload) { - print header(-type=>$formats{$format}->{'mime'}, -Content_length => $size, -attachment => "msg${msgid}.$format"); - } else { - print header(-type=>$formats{$format}->{'mime'}, -Content_length => $size); - } - - while(($amt = sysread(AUDIO, $data, 4096)) > 0) { - syswrite(STDOUT, $data, $amt); - } - close(AUDIO); - } else { - die("Hrm, can't seem to open $path\n"); - } -} - -sub message_index() -{ - my ($folder, $message) = @_; - my ($mbox, $context) = split(/\@/, param('mailbox')); - my $passwd = param('password'); - my $message2; - my $msgcount; - my $hasmsg; - my ($newmessages, $oldmessages); - my $format = param('format'); - if (!$format) { - $format = &getcookie('format'); - } - if (!$context) { - $context = param('context'); - } - if (!$context) { - $context = "default"; - } - if ($folder) { - $msgcount = &msgcountstr($context, $mbox, $folder); - $message2 = "   Folder '$folder' has " . &msgcountstr($context, $mbox, $folder); - } else { - $newmessages = &msgcount($context, $mbox, "INBOX"); - $oldmessages = &msgcount($context, $mbox, "Old"); - if (($newmessages > 0) || ($oldmessages < 1)) { - $folder = "INBOX"; - } else { - $folder = "Old"; - } - $message2 = "You have"; - if ($newmessages > 0) { - $message2 .= " $newmessages NEW"; - if ($oldmessages > 0) { - $message2 .= "and $oldmessages OLD"; - if ($oldmessages != 1) { - $message2 .= " messages."; - } else { - $message2 .= "message."; - } - } else { - if ($newmessages != 1) { - $message2 .= " messages."; - } else { - $message2 .= " message."; - } - } - } else { - if ($oldmessages > 0) { - $message2 .= " $oldmessages OLD"; - if ($oldmessages != 1) { - $message2 .= " messages."; - } else { - $message2 .= " message."; - } - } else { - $message2 .= " no messages."; - } - } - } - - my $folders = &folder_list('newfolder', $context, $mbox, $folder); - my $cfolders = &folder_list('changefolder', $context, $mbox, $folder); - my $mailboxes = &mailbox_list('forwardto', $context, $mbox); - print header(-cookie => &makecookie($format)); - print <<_EOH; - -Asterisk Web-Voicemail: $mbox\@$context $folder - -$stdcontainerstart - - - - - -
$message
$folder Messages $cfolders
$message2
- -_EOH - -print "\n"; -print "\n"; -foreach $msg (&messages($context, $mbox, $folder)) { - - $fields = &getfields($context, $mbox, $folder, $msg); - $duration = $fields->{'duration'}; - if ($duration) { - $duration = sprintf "%d:%02d", $duration / 60, $duration % 60; - } else { - $duration = "Unknown"; - } - $hasmsg++; - print "\n"; - -} -if (!$hasmsg) { - print ""; -} - -print <<_EOH; -
 Msg From Duration Date 




 $msg$fields->{'callerid'}$duration$fields->{'origdate'}

No messages

- - - -
-   -_EOH - -if ($hasmsg) { -print <<_EOH; -   - - $folders  - - $mailboxes -_EOH -} - -print <<_EOH; -
- - -
- - - - -
-$stdcontainerend -\n -_EOH -} - -sub validfolder() -{ - my ($folder) = @_; - return grep(/^$folder$/, @validfolders); -} - -sub folder_list() -{ - my ($name, $context, $mbox, $selected) = @_; - my $f; - my $count; - my $tmp = ""; -} - -sub message_rename() -{ - my ($context, $mbox, $oldfolder, $old, $newfolder, $new) = @_; - my ($oldfile, $newfile); - return if ($old eq $new) && ($oldfolder eq $newfolder); - - if ($context =~ /^(\w+)$/) { - $context = $1; - } else { - die("Invalid Context
\n"); - } - - if ($mbox =~ /^(\w+)$/) { - $mbox = $1; - } else { - die ("Invalid mailbox
\n"); - } - - if ($oldfolder =~ /^(\w+)$/) { - $oldfolder = $1; - } else { - die("Invalid old folder
\n"); - } - - if ($newfolder =~ /^(\w+)$/) { - $newfolder = $1; - } else { - die("Invalid new folder ($newfolder)
\n"); - } - - if ($old =~ /^(\d\d\d\d)$/) { - $old = $1; - } else { - die("Invalid old Message
\n"); - } - - if ($new =~ /^(\d\d\d\d)$/) { - $new = $1; - } else { - die("Invalid old Message
\n"); - } - - my $path = "/var/spool/asterisk/voicemail/$context/$mbox/$newfolder"; - $path =~ /^(.*)$/; - $path = $1; - mkdir $path, 0770; - $path = "/var/spool/asterisk/voicemail/$context/$mbox/$oldfolder"; - opendir(DIR, $path) || die("Unable to open directory\n"); - my @files = grep /^msg${old}\.\w+$/, readdir(DIR); - closedir(DIR); - foreach $oldfile (@files) { - my $tmp = $oldfile; - if ($tmp =~ /^(msg${old}.\w+)$/) { - $tmp = $1; - $oldfile = $path . "/$tmp"; - $tmp =~ s/msg${old}/msg${new}/; - $newfile = "/var/spool/asterisk/voicemail/$context/$mbox/$newfolder/$tmp"; -# print "Renaming $oldfile to $newfile
\n"; - rename($oldfile, $newfile); - } - } -} - -sub file_copy() -{ - my ($orig, $new) = @_; - my $res; - my $data; - $orig =~ /^(.*)$/; - $orig = $1; - $new =~ /^(.*)$/; - $new = $1; - open(IN, "<$orig") || die("Unable to open '$orig'\n"); - open(OUT, ">$new") || DIE("Unable to open '$new'\n"); - while(($res = sysread(IN, $data, 4096)) > 0) { - syswrite(OUT, $data, $res); - } - close(OUT); - close(IN); -} - -sub message_copy() -{ - my ($context, $mbox, $newmbox, $oldfolder, $old, $new) = @_; - my ($oldfile, $newfile); - return if ($mbox eq $newmbox); - - if ($mbox =~ /^(\w+)$/) { - $mbox = $1; - } else { - die ("Invalid mailbox
\n"); - } - - if ($newmbox =~ /^(\w+)$/) { - $newmbox = $1; - } else { - die ("Invalid new mailbox
\n"); - } - - if ($oldfolder =~ /^(\w+)$/) { - $oldfolder = $1; - } else { - die("Invalid old folder
\n"); - } - - if ($old =~ /^(\d\d\d\d)$/) { - $old = $1; - } else { - die("Invalid old Message
\n"); - } - - if ($new =~ /^(\d\d\d\d)$/) { - $new = $1; - } else { - die("Invalid old Message
\n"); - } - - my $path = "/var/spool/asterisk/voicemail/$context/$newmbox"; - $path =~ /^(.*)$/; - $path = $1; - mkdir $path, 0770; - $path = "/var/spool/asterisk/voicemail/$context/$newmbox/INBOX"; - $path =~ /^(.*)$/; - $path = $1; - mkdir $path, 0770; - $path = "/var/spool/asterisk/voicemail/$context/$mbox/$oldfolder"; - opendir(DIR, $path) || die("Unable to open directory\n"); - my @files = grep /^msg${old}\.\w+$/, readdir(DIR); - closedir(DIR); - foreach $oldfile (@files) { - my $tmp = $oldfile; - if ($tmp =~ /^(msg${old}.\w+)$/) { - $tmp = $1; - $oldfile = $path . "/$tmp"; - $tmp =~ s/msg${old}/msg${new}/; - $newfile = "/var/spool/asterisk/voicemail/$context/$newmbox/INBOX/$tmp"; -# print "Copying $oldfile to $newfile
\n"; - &file_copy($oldfile, $newfile); - } - } -} - -sub message_delete() -{ - my ($context, $mbox, $folder, $msg) = @_; - if ($mbox =~ /^(\w+)$/) { - $mbox = $1; - } else { - die ("Invalid mailbox
\n"); - } - if ($context =~ /^(\w+)$/) { - $context = $1; - } else { - die ("Invalid context
\n"); - } - if ($folder =~ /^(\w+)$/) { - $folder = $1; - } else { - die("Invalid folder
\n"); - } - if ($msg =~ /^(\d\d\d\d)$/) { - $msg = $1; - } else { - die("Invalid Message
\n"); - } - my $path = "/var/spool/asterisk/voicemail/$context/$mbox/$folder"; - opendir(DIR, $path) || die("Unable to open directory\n"); - my @files = grep /^msg${msg}\.\w+$/, readdir(DIR); - closedir(DIR); - foreach $oldfile (@files) { - if ($oldfile =~ /^(msg${msg}.\w+)$/) { - $oldfile = $path . "/$1"; -# print "Deleting $oldfile
\n"; - unlink($oldfile); - } - } -} - -sub message_forward() -{ - my ($toindex, @msgs) = @_; - my $folder = param('folder'); - my ($mbox, $context) = split(/\@/, param('mailbox')); - my $newmbox = param('forwardto'); - my $msg; - my $msgcount; - if (!$context) { - $context = param('context'); - } - if (!$context) { - $context = "default"; - } - $newmbox =~ s/(\w+)(\s+.*)?$/$1/; - if (!&validmailbox($context, $newmbox)) { - die("Bah! Not a valid mailbox '$newmbox'\n"); - return ""; - } - - my $txt; - $context = &untaint($context); - $newmbox = &untaint($newmbox); - my $path = "/var/spool/asterisk/voicemail/$context/$newmbox/INBOX"; - if ($msgs[0]) { - if (&lock_path($path) == 0) { - $msgcount = &msgcount($context, $newmbox, "INBOX"); - - if ($newmbox ne $mbox) { - # print header; - foreach $msg (@msgs) { - # print "Forwarding $msg from $mbox to $newmbox
\n"; - &message_copy($context, $mbox, $newmbox, $folder, $msg, sprintf "%04d", $msgcount); - $msgcount++; - } - $txt = "Forwarded messages " . join(', ', @msgs) . "to $newmbox"; - } else { - $txt = "Can't forward messages to yourself!\n"; - } - &unlock_path($path); - } else { - $txt = "Cannot forward messages: Unable to lock path.\n"; - } - } else { - $txt = "Please Select Message(s) for this action.\n"; - } - if ($toindex) { - &message_index($folder, $txt); - } else { - &message_play($txt, $msgs[0]); - } -} - -sub message_delete_or_move() -{ - my ($toindex, $del, @msgs) = @_; - my $txt; - my $path; - my ($y, $x); - my $folder = param('folder'); - my $newfolder = param('newfolder') unless $del; - $newfolder =~ s/^(\w+)\s+.*$/$1/; - my ($mbox, $context) = split(/\@/, param('mailbox')); - if (!$context) { - $context = param('context'); - } - if (!$context) { - $context = "default"; - } - my $passwd = param('password'); - $context = &untaint($context); - $mbox = &untaint($mbox); - $folder = &untaint($folder); - $path = "/var/spool/asterisk/voicemail/$context/$mbox/$folder"; - if ($msgs[0]) { - if (&lock_path($path) == 0) { - my $msgcount = &msgcount($context, $mbox, $folder); - my $omsgcount = &msgcount($context, $mbox, $newfolder) if $newfolder; - # print header; - if ($newfolder ne $folder) { - $y = 0; - for ($x=0;$x<$msgcount;$x++) { - my $msg = sprintf "%04d", $x; - my $newmsg = sprintf "%04d", $y; - if (grep(/^$msg$/, @msgs)) { - if ($newfolder) { - &message_rename($context, $mbox, $folder, $msg, $newfolder, sprintf "%04d", $omsgcount); - $omsgcount++; - } else { - &message_delete($context, $mbox, $folder, $msg); - } - } else { - &message_rename($context, $mbox, $folder, $msg, $folder, $newmsg); - $y++; - } - } - if ($del) { - $txt = "Deleted messages " . join (', ', @msgs); - } else { - $txt = "Moved messages " . join (', ', @msgs) . " to $newfolder"; - } - } else { - $txt = "Can't move a message to the same folder they're in already"; - } - &unlock_path($path); - } else { - $txt = "Cannot move/delete messages: Unable to lock path.\n"; - } - } else { - $txt = "Please Select Message(s) for this action.\n"; - } - # Not as many messages now - $msgcount--; - if ($toindex || ($msgs[0] >= $msgcount)) { - &message_index($folder, $txt); - } else { - &message_play($txt, $msgs[0]); - } -} - -if (param()) { - my $folder = param('folder'); - my $changefolder = param('changefolder'); - $changefolder =~ s/(\w+)\s+.*$/$1/; - - my $newfolder = param('newfolder'); - $newfolder =~ s/^(\w+)\s+.*$/$1/; - if ($newfolder && !&validfolder($newfolder)) { - print header; - die("Bah! new folder '$newfolder' isn't a folder."); - } - $action = param('action'); - $msgid = param('msgid'); - if (!$action) { - my ($tmp) = grep /^play\d\d\d\d\.x$/, param; - if ($tmp =~ /^play(\d\d\d\d)/) { - $msgid = $1; - $action = "play"; - } else { - print header; - print "No message?
\n"; - return; - } - } - @msgs = param('msgselect'); - @msgs = ($msgid) unless @msgs; - { - ($mailbox) = &check_login(); - if (length($mailbox)) { - if ($action eq 'login') { - &message_index($folder, "Welcome, $mailbox"); - } elsif (($action eq 'refresh') || ($action eq 'index')) { - &message_index($folder, "Welcome, $mailbox"); - } elsif ($action eq 'change to ->') { - if (&validfolder($changefolder)) { - $folder = $changefolder; - &message_index($folder, "Welcome, $mailbox"); - } else { - die("Bah! Not a valid change to folder '$changefolder'\n"); - } - } elsif ($action eq 'play') { - &message_play("$mailbox $folder $msgid", $msgid); - } elsif ($action eq 'preferences') { - &message_prefs("refresh", $msgid); - } elsif ($action eq 'download') { - &message_audio(1); - } elsif ($action eq 'play ') { - &message_audio(0); - } elsif ($action eq 'audio') { - &message_audio(0); - } elsif ($action eq 'delete') { - &message_delete_or_move(1, 1, @msgs); - } elsif ($action eq 'delete ') { - &message_delete_or_move(0, 1, @msgs); - } elsif ($action eq 'forward to ->') { - &message_forward(1, @msgs); - } elsif ($action eq 'forward to -> ') { - &message_forward(0, @msgs); - } elsif ($action eq 'save to ->') { - &message_delete_or_move(1, 0, @msgs); - } elsif ($action eq 'save to -> ') { - &message_delete_or_move(0, 0, @msgs); - } elsif ($action eq 'logout') { - &login_screen("Logged out!\n"); - } - } else { - sleep(1); - &login_screen("Login Incorrect!\n"); - } - } -} else { - &login_screen("\ "); -} diff --git a/contrib/scripts/vmdb.sql b/contrib/scripts/vmdb.sql deleted file mode 100644 index c8148cfcb..000000000 --- a/contrib/scripts/vmdb.sql +++ /dev/null @@ -1,64 +0,0 @@ -DROP TABLE IF EXISTS voicemail; -CREATE TABLE voicemail ( - -- All of these column names are very specific, including "uniqueid". Do not change them if you wish voicemail to work. - uniqueid INT(5) NOT NULL AUTO_INCREMENT PRIMARY KEY, - -- Mailbox context. - context CHAR(80) NOT NULL DEFAULT 'default', - -- Mailbox number. Should be numeric. - mailbox CHAR(80) NOT NULL, - -- Must be numeric. Negative if you don't want it to be changed from VoicemailMain - password CHAR(80) NOT NULL, - -- Used in email and for Directory app - fullname CHAR(80), - -- Email address (will get sound file if attach=yes) - email CHAR(80), - -- Email address (won't get sound file) - pager CHAR(80), - -- Attach sound file to email - YES/no - attach CHAR(3), - -- Which sound format to attach - attachfmt CHAR(10), - -- Send email from this address - serveremail CHAR(80), - -- Prompts in alternative language - language CHAR(20), - -- Alternative timezone, as defined in voicemail.conf - tz CHAR(30), - -- Delete voicemail from server after sending email notification - yes/NO - deletevoicemail CHAR(3), - -- Read back CallerID information during playback - yes/NO - saycid CHAR(3), - -- Allow user to send voicemail from within VoicemailMain - YES/no - sendvoicemail CHAR(3), - -- Listen to voicemail and approve before sending - yes/NO - review CHAR(3), - -- Warn user a temporary greeting exists - yes/NO - tempgreetwarn CHAR(3), - -- Allow '0' to jump out during greeting - yes/NO - operator CHAR(3), - -- Hear date/time of message within VoicemailMain - YES/no - envelope CHAR(3), - -- Hear length of message within VoicemailMain - yes/NO - sayduration CHAR(3), - -- Minimum duration in minutes to say - saydurationm INT(3), - -- Force new user to record name when entering voicemail - yes/NO - forcename CHAR(3), - -- Force new user to record greetings when entering voicemail - yes/NO - forcegreetings CHAR(3), - -- Context in which to dial extension for callback - callback CHAR(80), - -- Context in which to dial extension (from advanced menu) - dialout CHAR(80), - -- Context in which to execute 0 or * escape during greeting - exitcontext CHAR(80), - -- Maximum messages in a folder (100 if not specified) - maxmsg INT(5), - -- Increase DB gain on recorded message by this amount (0.0 means none) - volgain DECIMAL(5,2), - -- IMAP user for authentication (if using IMAP storage) - imapuser VARCHAR(80), - -- IMAP password for authentication (if using IMAP storage) - imappassword VARCHAR(80), - stamp timestamp -); -- cgit v1.2.3