From ec3ab19d02c965f1e6fbb282a29b4eca7c09561f Mon Sep 17 00:00:00 2001 From: mattf Date: Mon, 17 Jul 2006 16:39:07 +0000 Subject: [PATCH] added DBI-version ofAST_reset_mysql_vars.pl to DBI-scripts directory git-svn-id: svn://192.168.202.10@58 3d104415-ff17-0410-8863-d5cf3c621b8a --- DBI-scripts/AST_reset_mysql_vars.pl | 73 +++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 DBI-scripts/AST_reset_mysql_vars.pl diff --git a/DBI-scripts/AST_reset_mysql_vars.pl b/DBI-scripts/AST_reset_mysql_vars.pl new file mode 100644 index 0000000..90eaf78 --- /dev/null +++ b/DBI-scripts/AST_reset_mysql_vars.pl @@ -0,0 +1,73 @@ +#!/usr/bin/perl +# +# AST_reset_mysql_vars.pl version 0.3 *DBI-version* +# +# !!! DO NOT RUN THIS WHILE THERE ARE ACTIVE CALLS ON THE ASTERISK SERVER !!! +# +# DESCRIPTION: +# clears out mysql records for this server +# +# It is recommended that you run this program on the local Asterisk machine +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# CHANGES +# 60717-1237 - changed to DBI by Marin Blu +# + +### Make sure this file is in a libs path or put the absolute path to it +require("/home/cron/AST_SERVER_conf.pl"); # local configuration file + +if (!$DB_port) {$DB_port='3306';} + +use DBI; + +$dbhA = DBI->connect("DBI:mysql:$DB_database:$DB_server:$DB_port", "$DB_user", "$DB_pass") + or die "Couldn't connect to database: " . DBI->errstr; + + + $stmtA = "UPDATE conferences set extension='' where server_ip='$server_ip';"; + if($DB){print STDERR "\n|$stmtA|\n";} + $affected_rows = $dbhA->do($stmtA); # or die "Couldn't execute query: |$stmtA|\n"; + print " - conferences reset\n"; + + $stmtA = "UPDATE vicidial_conferences set extension='' where server_ip='$server_ip';"; + if($DB){print STDERR "\n|$stmtA|\n";} + $affected_rows = $dbhA->do($stmtA); # or die "Couldn't execute query: |$stmtA|\n"; + print " - vicidial_conferences reset\n"; + +# $stmtA = "UPDATE vicidial_manager set status='DEAD' where server_ip='$server_ip' and status='NEW';"; +# if($DB){print STDERR "\n|$stmtA|\n";} +# $dbhA->query($stmtA); # or die "Couldn't execute query: |$stmtA|\n"; +# print " - vicidial_manager queue reset\n"; + + $stmtA = "DELETE from vicidial_manager where server_ip='$server_ip';"; + if($DB){print STDERR "\n|$stmtA|\n";} + $affected_rows = $dbhA->do($stmtA); # or die "Couldn't execute query: |$stmtA|\n"; + print " - vicidial_manager delete\n"; + + $stmtA = "DELETE from vicidial_auto_calls where server_ip='$server_ip';"; + if($DB){print STDERR "\n|$stmtA|\n";} + $affected_rows = $dbhA->do($stmtA); # or die "Couldn't execute query: |$stmtA|\n"; + print " - vicidial_auto_calls delete\n"; + + $stmtA = "DELETE from vicidial_live_agents where server_ip='$server_ip';"; + if($DB){print STDERR "\n|$stmtA|\n";} + $affected_rows = $dbhA->do($stmtA); # or die "Couldn't execute query: |$stmtA|\n"; + print " - vicidial_live_agents delete\n"; + + $stmtA = "DELETE from vicidial_users where full_name='5555';"; + if($DB){print STDERR "\n|$stmtA|\n";} + $affected_rows = $dbhA->do($stmtA); # or die "Couldn't execute query: |$stmtA|\n"; + print " - vicidial__users delete\n"; + + $dbhA->disconnect(); + + +exit; + + + + + +