3 # Copyright (C) 2013 Cisco Systems, Inc.
5 # This program and the accompanying materials are made available under the
6 # terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 # and is available at http://www.eclipse.org/legal/epl-v10.html
9 # Authors : Thomas Bachman
14 currname=`cat /etc/hostname`
15 echo "Current hostname: $currname"
17 echo -n "Enter new hostname: "
21 # Update /etc/hosts & /etc/hostname with new hostname
23 if [ "$newname" != "$currname" ]; then
24 res=`sed -i "s/$currname/$newname/g" /etc/hosts`
26 echo "failed to update /etc/hosts"
28 res=`sed -i "s/$currname/$newname/g" /etc/hostname`
30 echo "failed to update /etc/hostname"
32 res=`hostname $newname`
34 echo "failed to update hostname"
36 echo "Your new hostname is $newname"
39 echo "hostname already set to $newname"