1218799Snwhitehorn#!/bin/sh
2218799Snwhitehorn#-
3218799Snwhitehorn# Copyright (c) 2011 Nathan Whitehorn
4287687Sdteske# Copyright (c) 2015 Devin Teske
5218799Snwhitehorn# All rights reserved.
6218799Snwhitehorn#
7218799Snwhitehorn# Redistribution and use in source and binary forms, with or without
8218799Snwhitehorn# modification, are permitted provided that the following conditions
9218799Snwhitehorn# are met:
10218799Snwhitehorn# 1. Redistributions of source code must retain the above copyright
11218799Snwhitehorn#    notice, this list of conditions and the following disclaimer.
12218799Snwhitehorn# 2. Redistributions in binary form must reproduce the above copyright
13218799Snwhitehorn#    notice, this list of conditions and the following disclaimer in the
14218799Snwhitehorn#    documentation and/or other materials provided with the distribution.
15218799Snwhitehorn#
16218799Snwhitehorn# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17218799Snwhitehorn# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18218799Snwhitehorn# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19218799Snwhitehorn# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20218799Snwhitehorn# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21218799Snwhitehorn# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22218799Snwhitehorn# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23218799Snwhitehorn# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24218799Snwhitehorn# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25218799Snwhitehorn# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26218799Snwhitehorn# SUCH DAMAGE.
27218799Snwhitehorn#
28218799Snwhitehorn# $FreeBSD$
29218799Snwhitehorn
30218799Snwhitehorn: ${DIALOG_OK=0}
31218799Snwhitehorn: ${DIALOG_CANCEL=1}
32218799Snwhitehorn: ${DIALOG_HELP=2}
33218799Snwhitehorn: ${DIALOG_EXTRA=3}
34218799Snwhitehorn: ${DIALOG_ITEM_HELP=4}
35218799Snwhitehorn: ${DIALOG_ESC=255}
36218799Snwhitehorn
37218799Snwhitehornexec 3>&1
38218799SnwhitehornHOSTNAME=`dialog --backtitle 'FreeBSD Installer' --title 'Set Hostname' --nocancel --inputbox \
39218799Snwhitehorn	'Please choose a hostname for this machine.
40218799Snwhitehorn
41218799SnwhitehornIf you are running on a managed network, please ask your network administrator for an appropriate name.' \
42218799Snwhitehorn	0 0 $(hostname) 2>&1 1>&3`
43218799Snwhitehornif [ $? -eq $DIALOG_CANCEL ]; then exit 1; fi
44218799Snwhitehornexec 3>&-
45218799Snwhitehorn
46218799Snwhitehornecho "hostname=\"$HOSTNAME\"" > $BSDINSTALL_TMPETC/rc.conf.hostname
47287686Sdteskeretval=$?
48287686Sdteskeif [ "$BSDINSTALL_CONFIGCURRENT" ]; then
49218799Snwhitehorn	hostname -s "$HOSTNAME"
50287686Sdteske	retval=$?
51218799Snwhitehornfi
52287686Sdteskeexit $retval
53