#!/bin/bash # Set the hostname on the node inside /etc/hostname and /etc/hosts # # Example usage (on guest): # vn-sethostname base node1 # changes the hostname from base to node1 # # Assumptions: # - The first instance of the old host name is the only one to change # in the files. # # For more info see: http://sandilands.info/sgordon/virtnet # # $Revision$ # $Author$ # $Date$ # $URL$ # Input parameters # Old host name basevm=$1 # New host name vmname=$2 # Use sed to replace the old host name with the new host name sed -i "s/${basevm}/${vmname}/" /etc/hostname sed -i "s/${basevm}/${vmname}/" /etc/hosts hostname -F /etc/hostname