/usr/bin/whups-obliterate is in php-horde-whups 3.0.0-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | #!/usr/bin/env php
<?php
/**
* Obliterate Whups Data.
*
* This script deletes all queues, types, and tickets from the current Whups
* database.
*
* Copyright 2004-2014 Horde LLC (http://www.horde.org/)
*
* @author Jon Parise <jon@horde.org>
*/
if (file_exists(__DIR__ . '/../../whups/lib/Application.php')) {
$baseDir = __DIR__ . '/../';
} else {
require_once 'PEAR/Config.php';
$baseDir = PEAR_Config::singleton()
->get('horde_dir', null, 'pear.horde.org') . '/whups/';
}
require_once $baseDir . 'lib/Application.php';
Horde_Registry::appInit('whups', array('cli' => true, 'user_admin' => true));
$confirm = $cli->prompt(
'Are you sure you want to obliterate all Whups data?',
array(
'n' => 'No',
'y' => 'Yes'));
$cli->writeln();
if ($confirm !== 'y') {
exit;
}
$GLOBALS['whups_driver'] = $injector->getInstance('Whups_Factory_Driver')->create();
$cli->writeln($cli->bold('Obliterating queues'));
$queues = $whups_driver->getQueues();
foreach ($queues as $queue_id => $queue_name) {
$cli->message("Deleting queue: $queue_name");
$whups_driver->deleteQueue($queue_id);
}
$cli->writeln();
$cli->writeln($cli->bold('Obliterating types'));
$types = $whups_driver->getAllTypes();
foreach ($types as $type_id => $type_name) {
$cli->message("Deleting type: $type_name");
$whups_driver->deleteType($type_id);
}
$cli->writeln();
$queues = $registry->tickets->listQueues();
$cli->writeln($cli->bold('Obliterating tickets'));
$cli->writeln();
foreach (array_keys($queues) as $queue) {
$info['queue_id'] = $queue;
$tickets = $whups_driver->getTicketsByProperties($info);
foreach ($tickets as $info) {
$cli->message('Deleting ticket: ' . $info['id']);
$ticket = Whups_Ticket::makeTicket($info['id']);
$ticket->delete();
}
}
|