2010-09-03 18:26:59 +00:00
|
|
|
#!/usr/bin/env php
|
2009-09-07 11:07:59 +00:00
|
|
|
<?php
|
|
|
|
|
2015-07-10 13:36:21 +02:00
|
|
|
/*
|
2013-10-28 12:01:36 -07:00
|
|
|
* Observium
|
2012-05-09 10:01:42 +00:00
|
|
|
*
|
2013-10-28 12:01:36 -07:00
|
|
|
* This file is part of Observium.
|
2012-05-09 10:01:42 +00:00
|
|
|
*
|
2013-10-28 12:01:36 -07:00
|
|
|
* @package observium
|
2012-05-09 10:01:42 +00:00
|
|
|
* @subpackage cli
|
2013-10-28 12:01:36 -07:00
|
|
|
* @author Adam Armstrong <adama@memetic.org>
|
|
|
|
* @copyright (C) 2006 - 2012 Adam Armstrong
|
2012-05-09 10:01:42 +00:00
|
|
|
*/
|
|
|
|
|
2012-04-08 10:44:41 +00:00
|
|
|
chdir(dirname($argv[0]));
|
|
|
|
|
2015-07-10 13:36:21 +02:00
|
|
|
require 'includes/defaults.inc.php';
|
|
|
|
require 'config.php';
|
|
|
|
require 'includes/definitions.inc.php';
|
|
|
|
require 'includes/functions.php';
|
2009-03-11 14:50:24 +00:00
|
|
|
|
2015-07-10 13:36:21 +02:00
|
|
|
// Remove a host and all related data from the system
|
|
|
|
if ($argv[1] && $argv[2]) {
|
|
|
|
$host = strtolower($argv[1]);
|
|
|
|
$id = getidbyname($host);
|
|
|
|
if ($id) {
|
|
|
|
$tohost = strtolower($argv[2]);
|
|
|
|
$toid = getidbyname($tohost);
|
|
|
|
if ($toid) {
|
|
|
|
echo "NOT renamed. New hostname $tohost already exists.\n";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
renamehost($id, $tohost, 'console');
|
|
|
|
echo "Renamed $host\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
echo "Host doesn't exist!\n";
|
2012-04-07 22:31:45 +00:00
|
|
|
}
|
2011-03-12 08:50:47 +00:00
|
|
|
}
|
2015-07-10 13:36:21 +02:00
|
|
|
else {
|
|
|
|
echo "Host Rename Tool\nUsage: ./renamehost.php <old hostname> <new hostname>\n";
|
2009-03-11 14:50:24 +00:00
|
|
|
}
|