mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Detect if the destination of a rename is already in the system.
Patch by RobJE. git-svn-id: http://www.observium.org/svn/observer/trunk@2985 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -13,8 +13,15 @@ if ($argv[1] && $argv[2])
|
||||
$id = getidbyname($host);
|
||||
if ($id)
|
||||
{
|
||||
renamehost($id, $argv[2], 'console');
|
||||
echo("Renamed $host\n");
|
||||
$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");
|
||||
}
|
||||
|
Reference in New Issue
Block a user