mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Add renamehost function result handling and exit codes (#12980)
This commit is contained in:
@ -23,13 +23,22 @@ if ($argv[1] && $argv[2]) {
|
||||
$toid = getidbyname($tohost);
|
||||
if ($toid) {
|
||||
echo "NOT renamed. New hostname $tohost already exists.\n";
|
||||
exit(1);
|
||||
} else {
|
||||
renamehost($id, $tohost, 'console');
|
||||
$result = renamehost($id, $tohost, 'console');
|
||||
if ($result == '') {
|
||||
echo "Renamed $host\n";
|
||||
exit(0);
|
||||
} else {
|
||||
echo "NOT renamed: $result";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo "Host doesn't exist!\n";
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
echo "Host Rename Tool\nUsage: ./renamehost.php <old hostname> <new hostname>\n";
|
||||
exit(1);
|
||||
}
|
||||
|
Reference in New Issue
Block a user