#!/bin/bash

if [ -z "$1" ]; then
 echo "WARNING; This will purge ALL of your CDR/CEL records permanently."
 echo "If you are sure you really want to do this, use the syntax below:"
 echo "Syntax: ./purge-cdr-cel-records YES"
 exit 0
fi

if [ "$1" != "YES" ]; then
 echo "WARNING; This will purge ALL of your CDR/CEL records permanently."
 echo "If you are sure you really want to do this, use the syntax below:"
 echo "Syntax: ./purge-cdr-cel-records YES"
 exit 0
fi


mysql -u root -ppassw0rd asteriskcdrdb -e "truncate table cdr"
mysql -u root -ppassw0rd asteriskcdrdb -e "truncate table cel"

echo "All CDR and CEL records have been purged as requested."
