head	1.2;
access;
symbols;
locks; strict;
comment	@# @;


1.2
date	2004.10.22.14.00.23;	author peter;	state Exp;
branches;
next	1.1;

1.1
date	2001.04.25.03.43.29;	author garbled;	state Exp;
branches;
next	;


desc
@@


1.2
log
@Don't ignore the hostname setting in /etc/rc.conf but use it if it exists.
Also change the 'hostname -s' command to 'hostname' because the full name
is what we want.

Fixes my PR bin/25038.
Approved by christos.
@
text
@#!/bin/sh
# $NetBSD: script,v 1.1 2001/04/25 03:43:29 garbled Exp $

if [ "$2" = "both" -o "$2" = "boot" ]; then
	. /etc/rc.conf
	# $hostname is not set in rc.conf and /etc/myname exists
	if [ -z "$hostname" ] && [ -f "/etc/myname" ]; then
		echo "$1" >/etc/myname
	# $hostname is set in rc.conf, edit it
	elif [ -n "$hostname" ]; then
		sed "s/hostname=.*/hostname=\"$1\"/" < /etc/rc.conf \
		    > /etc/rc.conf.new
		mv /etc/rc.conf.new /etc/rc.conf
	# Nothing is set, so set the new hostname in rc.conf
	else
		echo "hostname=\"$1\"" >>/etc/rc.conf
	fi	
fi
if [ "$2" = "both" -o "$2" = "now" ]; then
	hostname $1
fi
if [ $? -eq 0 ]; then
	echo "Hostname has been changed to $1"
else
	echo "Failed to change hostname to $1"
fi
@


1.1
log
@Whew.  Add an entire networking configuration tree for sushi.  This gives
sushi the ability to do the following tasks:
Edit /etc/exports
Edit /etc/hosts
Change the hostname
Modify NIC configuration
Change the default route
Setup YP/NIS.
@
text
@d2 1
a2 1
# $NetBSD$
d5 13
a17 1
	echo "$1" >/etc/myname
d22 1
a22 1
if [ "$?" = "0" ]; then
@

