Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bsdinstall/scripts/hostname
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | |||||
# | # | ||||
# Default file to store hostname entry in | # Default file to store hostname entry in | ||||
# | # | ||||
: ${HOSTNAMEFILE:=$BSDINSTALL_TMPETC/rc.conf.hostname} | : ${HOSTNAMEFILE:=$BSDINSTALL_TMPETC/rc.conf.hostname} | ||||
############################################################ GLOBALS | ############################################################ GLOBALS | ||||
: ${BSDDIALOG_CANCEL=1} | |||||
# | # | ||||
# Strings that should be moved to an i18n file and loaded with f_include_lang() | # Strings that should be moved to an i18n file and loaded with f_include_lang() | ||||
# | # | ||||
msg_freebsd_installer="FreeBSD Installer" | msg_freebsd_installer="FreeBSD Installer" | ||||
msg_ok="OK" | msg_ok="OK" | ||||
msg_please_choose_a_hostname="Please choose a hostname for this machine.\n\nIf you are running on a managed network, please ask\nyour network administrator for an appropriate name." | msg_please_choose_a_hostname="Please choose a hostname for this machine.\n\nIf you are running on a managed network, please ask\nyour network administrator for an appropriate name." | ||||
msg_set_hostname="Set Hostname" | msg_set_hostname="Set Hostname" | ||||
# | # | ||||
# Command strings for various tasks | # Command strings for various tasks | ||||
# | # | ||||
ECHO_OVERWRITE='echo "%s" > "%s"' | ECHO_OVERWRITE='echo "%s" > "%s"' | ||||
SET_HOSTNAME='hostname -s "%s"' | SET_HOSTNAME='hostname -s "%s"' | ||||
############################################################ FUNCTIONS | ############################################################ FUNCTIONS | ||||
# dialog_hostname | # dialog_hostname | ||||
# | # | ||||
# Display input box (without cancel button) for user to enter desired hostname. | # Display input box (without cancel button) for user to enter desired hostname. | ||||
# | # | ||||
dialog_hostname() | dialog_hostname() | ||||
{ | { | ||||
local prompt="$msg_please_choose_a_hostname" | local prompt="$msg_please_choose_a_hostname" | ||||
local hline= | local hline="Use TAB and Enter to select $msg_ok" | ||||
local value="$*" | local value="$*" | ||||
local height width | bsddialog \ | ||||
f_dialog_inputbox_size height width \ | |||||
"$DIALOG_TITLE" "$DIALOG_BACKTITLE" "$prompt" "$value" "$hline" | |||||
$DIALOG \ | |||||
--title "$DIALOG_TITLE" \ | --title "$DIALOG_TITLE" \ | ||||
--backtitle "$DIALOG_BACKTITLE" \ | --backtitle "$DIALOG_BACKTITLE" \ | ||||
--hline "$hline" \ | --hline "$hline" \ | ||||
--ok-label "$msg_ok" \ | --ok-label "$msg_ok" \ | ||||
--no-cancel \ | --no-cancel \ | ||||
--inputbox "$prompt" \ | --inputbox "$prompt" \ | ||||
$height $width "$value" \ | 0 56 "$value" \ | ||||
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD | 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD | ||||
} | } | ||||
############################################################ MAIN | ############################################################ MAIN | ||||
# | # | ||||
# Initialize | # Initialize | ||||
# | # | ||||
f_dialog_title "$msg_set_hostname" | f_dialog_title "$msg_set_hostname" | ||||
f_dialog_backtitle "$msg_freebsd_installer" | f_dialog_backtitle "$msg_freebsd_installer" | ||||
# | # | ||||
# Get user input | # Get user input | ||||
# | # | ||||
HOSTNAME=$( dialog_hostname "$HOSTNAME" ) | HOSTNAME=$( dialog_hostname "$HOSTNAME" ) | ||||
[ $? -eq $DIALOG_CANCEL ] && exit 1 | [ $? -eq $BSDDIALOG_CANCEL ] && exit 1 | ||||
# | # | ||||
# Store the user's choice | # Store the user's choice | ||||
# | # | ||||
f_eval_catch "$pgm" echo "$ECHO_OVERWRITE" \ | f_eval_catch "$pgm" echo "$ECHO_OVERWRITE" \ | ||||
'hostname=\"$HOSTNAME\"' "$HOSTNAMEFILE" | 'hostname=\"$HOSTNAME\"' "$HOSTNAMEFILE" | ||||
retval=$? | retval=$? | ||||
Show All 13 Lines |