initial commit of file from CVS for smeserver-freepbx on Sat Sep 7 20:25:35 AEST 2024
This commit is contained in:
62
root/usr/share/freepbx/scripts/restore-astdb.php
Normal file
62
root/usr/share/freepbx/scripts/restore-astdb.php
Normal file
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
// No use outputting anything, as env forces php headers to appear. Sigh.
|
||||
|
||||
|
||||
// Astdb trees that should be deleted before the restore
|
||||
//
|
||||
$deltree = array(
|
||||
'AMPUSER',
|
||||
'DEVICE',
|
||||
'CF',
|
||||
'CFB',
|
||||
'CFU',
|
||||
'CW',
|
||||
'DND',
|
||||
'DAYNIGHT',
|
||||
);
|
||||
|
||||
function getconf($filename) {
|
||||
$file = file($filename);
|
||||
foreach ($file as $line) {
|
||||
if (preg_match("/^\s*([\w]+)\s*=\s*\"?([\w\/\:\.\%-]*)\"?\s*([;#].*)?/",$line,$matches)) {
|
||||
$conf[ $matches[1] ] = $matches[2];
|
||||
}
|
||||
}
|
||||
return $conf;
|
||||
}
|
||||
|
||||
$amp_conf = getconf("/etc/amportal.conf");
|
||||
|
||||
require_once($amp_conf['AMPWEBROOT']."/admin/common/php-asmanager.php");
|
||||
|
||||
$astman = new AGI_AsteriskManager();
|
||||
if (! $res = $astman->connect("127.0.0.1", $amp_conf["AMPMGRUSER"] , $amp_conf["AMPMGRPASS"])) {
|
||||
unset( $astman );
|
||||
}
|
||||
|
||||
$dump = file_get_contents("/home/e-smith/db/freepbx/astdb.dump");
|
||||
|
||||
// Before restoring, let's clear out all of the current settings for the main objects
|
||||
// but as a safety, if the dump file is empy, we won't clear it out.
|
||||
//
|
||||
if (!empty($dump)) {
|
||||
$arr = explode("\n", $dump);
|
||||
foreach ($deltree as $family) {
|
||||
$astman->database_deltree($family);
|
||||
}
|
||||
foreach ($arr as $line) {
|
||||
$result = preg_match("/\[(.+)\] \[(.+)\]/", $line, $matches);
|
||||
// Now, the bad ones we know about are the ones that start with //, anything starting with SIP or IAX,
|
||||
// and RG (which are only temporary anyway).
|
||||
if (!isset($matches[1]) || $matches[1] == "") { continue; }
|
||||
$pattern = "/(^\/\/)|(^\/IAX)|(^\/SIP)|(^\/RG)|(^\/BLKVM)|(^\/FM)|(^\/dundi)/";
|
||||
if (preg_match($pattern, $matches[1])) { continue; }
|
||||
preg_match("/(.+)\/(.+)$/", $matches[1], $famkey);
|
||||
$famkey[1]=trim($famkey[1], '/');
|
||||
$astman->database_put($famkey[1], $famkey[2], '"'.$matches[2].'"');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
36
root/usr/share/freepbx/scripts/uninstall.sh
Normal file
36
root/usr/share/freepbx/scripts/uninstall.sh
Normal file
@@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
clear
|
||||
echo "----------------------------"
|
||||
echo "!!!!! WARNING !!!!!"
|
||||
echo "----------------------------"
|
||||
echo ""
|
||||
echo "This script will remove from your server:"
|
||||
echo " - freepbx and asterisk cdr MySQL databases"
|
||||
echo " - freepbx MySQL User"
|
||||
echo " - freepbx DB entries (freepbx, httpd-fpbx and dahdi)"
|
||||
echo " - /opt/freepbx"
|
||||
echo ""
|
||||
echo -n "Are you sure you want to remove FreePBX permanently ? (y/n) [n] "
|
||||
read confirm
|
||||
if [ "$confirm" = "y" -o "$confirm" = "Y" ]; then
|
||||
echo "Droping MySQL databases..."
|
||||
DBNAME=$(/sbin/e-smith/db configuration getprop freepbx DbName)
|
||||
CDRDBNAME=$(/sbin/e-smith/db configuration getprop freepbx CdrDbName)
|
||||
mysql -e "DROP DATABASE $DBNAME"
|
||||
mysql -e "DROP DATABASE $CDRDBNAME"
|
||||
echo "Deleting MySQL User..."
|
||||
DBUSER=$(/sbin/e-smith/db configuration getprop freepbx DbUser)
|
||||
mysql -u root -e "REVOKE ALL PRIVILEGES ON *.* FROM '$DBUSER'@'localhost';"
|
||||
mysql -u root -e "DROP USER '$DBUSER'@'localhost';" > /dev/null 2>&1
|
||||
echo "Removing SME DB entries..."
|
||||
/sbin/e-smith/db configuration delete freepbx
|
||||
/sbin/e-smith/db configuration delete httpd-fpbx
|
||||
/sbin/e-smith/db configuration delete dahdi
|
||||
echo "Removing /opt/freepbx ..."
|
||||
rm -rf /opt/freepbx
|
||||
echo "Removing this script ..."
|
||||
rm -f /root/uninstall-freepbx.sh
|
||||
echo "Done!"
|
||||
fi
|
||||
|
Reference in New Issue
Block a user