From owner-freebsd-questions@FreeBSD.ORG Thu Apr 21 21:25:12 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 10F04106564A; Thu, 21 Apr 2011 21:25:12 +0000 (UTC) (envelope-from Devin.Teske@fisglobal.com) Received: from mx1.fisglobal.com (mx1.fisglobal.com [199.200.24.190]) by mx1.freebsd.org (Postfix) with ESMTP id ADF6E8FC19; Thu, 21 Apr 2011 21:25:11 +0000 (UTC) Received: from sbhfislrext01.fnfis.com ([192.168.249.167]) by SCSFISLTC02 (8.14.3/8.14.3) with ESMTP id p3LLPAjf001075; Thu, 21 Apr 2011 16:25:10 -0500 Received: from sbhfisltcgw02.FNFIS.COM (Not Verified[10.132.248.122]) by sbhfislrext01.fnfis.com with MailMarshal (v6, 5, 4, 7535) id ; Thu, 21 Apr 2011 16:25:03 -0500 Received: from sbhfisltcgw02.FNFIS.COM ([10.132.248.122]) by sbhfisltcgw02.FNFIS.COM with Microsoft SMTPSVC(6.0.3790.4675); Thu, 21 Apr 2011 16:25:10 -0500 Received: from dtwin ([10.132.254.135]) by sbhfisltcgw02.FNFIS.COM over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Thu, 21 Apr 2011 16:25:06 -0500 From: "Devin Teske" To: , Date: Thu, 21 Apr 2011 14:24:35 -0700 Organization: Vicor, Inc. Message-ID: <02a701cc006a$887da210$9978e630$@vicor.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 14.0 Thread-Index: AcwAZojr2S8H9KcjT0+Gt5oHQUc5ZA== Content-Language: en-us X-OriginalArrivalTime: 21 Apr 2011 21:25:07.0803 (UTC) FILETIME=[967A42B0:01CC006A] Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: "Teske, Devin" Subject: [UPDATE] host-setup(1): a dialog(1)-based utility for configuring FreeBSD X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Apr 2011 21:25:12 -0000 Hi List Members! I'm proud to announce the first update to my host-setup utility (a dialog(1)-based host configurator for FreeBSD). The following changes have been made: - fixed bug where /etc/resolv.conf would be created with 0600 permissions - fixed bug when switching from one default gateway to NO default gateway - fixed typo in the title of netmask prompt and ifconfig options dialog - fixed bug that prevented entry of netmask if no netmask is configured You can get the updated version here: http://druidbsd.sourceforge.net/download/host-setup.txt or http://druidbsd.sourceforge.net/download/host-setup.gz or http://druidbsd.sourceforge.net/ For those not familiar with my host-setup(1) utility, it is a 2,500+ line shell script that utilizes the dialog(1) utility to walk the system administrator through setting up their TimeZone, Hostname, Network Interfaces, Default Gateway, and DNS. Our custom FreeBSD installer sets this script as the root login shell, making it very easy for field engineers to quickly get a system on the network without having to use the command-line (and without having to reboot either). Underneath the hood - behind the system of prompts and dialogs - this script manages both the contents of /etc/rc.conf, /etc/resolv.conf, and others as well as utilizing ifconfig(8), route(8), and many other tools to avoid requiring a reboot, prompting you if you would like to make the new changes effective when values are changed from their active settings. Here's the patch to show the details: --- host-setup.3_0 2011-02-10 19:14:30.000000000 -0800 +++ host-setup 2011-04-21 13:38:58.000000000 -0700 @@ -2,12 +2,12 @@ # -*- tab-width: 4 -*- ;; Emacs # vi: set tabstop=4 :: Vi/ViM # -# Revision: 3.0 +# Revision: 3.1 # Created: September 21st, 2010 -# Last Modified: December 6th, 2010 +# Last Modified: April 21st, 2011 ############################################################ COPYRIGHT # -# Devin Teske (c)2006-2010. All Rights Reserved. +# Devin Teske (c)2006-2011. All Rights Reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -1353,8 +1353,10 @@ dialog_input_hostname() # permissions and ownership to match resolv.conf(5) before # we write it out and mv(1) it into place). # - quietly chmod "$( stat -f '%#Lp' "$RESOLV_CONF" )" "$tmpfile" - quietly chown "$( stat -f '%u:%g' "$RESOLV_CONF" )" "$tmpfile" + local mode="$( stat -f '%#Lp' "$RESOLV_CONF" 2> /dev/null )" + local owner="$( stat -f '%u:%g' "$RESOLV_CONF" 2> /dev/null )" + quietly chmod "${mode:-0644}" "$tmpfile" + quietly chown "${owner:-root:wheel}" "$tmpfile" # # Operate on resolv.conf(5), replacing only the last @@ -1646,7 +1648,7 @@ dialog_input_netmask() # while :; do - dialog --title "$brand${band:+}${progname:-$0}" \ + dialog --title "$brand${brand:+ }${progname:-$0}" \ --hline "Use numbers, punctuation, TAB or ENTER" \ --inputbox "$msg" 10 50 \ "$_netmask" \ @@ -1664,7 +1666,7 @@ dialog_input_netmask() [ $retval -eq $SUCCESS ] || return $retval # Return success if NULL value was entered - [ "$_netmask" ] || return $SUCCESS + [ "$_input" ] || return $SUCCESS # Take only the first "word" of the user's input _netmask="$_input" @@ -1705,7 +1707,7 @@ dialog_input_options() msg="Please enter additional network media options to be" msg="$msg passed to ifconfig(8) for the $interface interface:" - dialog --title "$brand${band:+}${progname:-$0}" \ + dialog --title "$brand${brand:+ }${progname:-$0}" \ --hline "Use numbers, punctuation, TAB or ENTER" \ --inputbox "$msg" 9 70 \ "$options" \ @@ -2183,9 +2185,12 @@ dialog_menu_netdev_edit() local dr="$( sysrc_get defaultrouter )" err err=$( ifconfig $interface inet $ipaddr \ netmask $netmask $options 2>&1 ) - if [ $? -eq $SUCCESS -a "$dr" ]; then - err=$( route add default "$dr" 2>&1 ) - [ $? -eq $SUCCESS ] || dialog_msgbox "$err" + if [ $? -eq $SUCCESS ]; then + if [ "$dr" -a "$dr" != "NO" ]; then + err=$( route add default "$dr" 2>&1 ) + [ $? -eq $SUCCESS ] || \ + dialog_msgbox "$err" + fi else dialog_msgbox "$err" fi @@ -2524,7 +2529,7 @@ exit $SUCCESS # # $Header$ # -# $Copyright: 2006-2010. Devin Teske. All Rights Reserved. $ +# $Copyright: 2006-2011. Devin Teske. All Rights Reserved. $ # # $Log$ # -- Cheers, Devin Teske -> FUN STUFF <- -----BEGIN GEEK CODE BLOCK----- Version 3.12 GAT/CS/B/CC/E/IT/MC/M/MU/P/S/TW d+(++) s: a- C+++@$ UB++++$ P++++@$ L++++$ E- W+++ N? o? K? w@ O M++$ V- PS+>++ PE@ Y+ PGP-> t(+) 5? X(+) R(-) tv+ b+>++ DI+ D+(++) G++ e>++++ h r+++ z+++ ------END GEEK CODE BLOCK------ Learn about the "Geek Code": http://www.geekcode.com/ -> LEGAL DISCLAIMER <- This message contains confidential and proprietary information of the sender, and is intended only for the person(s) to whom it is addressed. Any use, distribution, copying or disclosure by any other person is strictly prohibited. If you have received this message in error, please notify the e-mail sender immediately, and delete the original message without making a copy. -> END TRANSMISSION <- _____________ The information contained in this message is proprietary and/or confidential. If you are not the intended recipient, please: (i) delete the message and all copies; (ii) do not disclose, distribute or use the message in any manner; and (iii) notify the sender immediately. In addition, please be aware that any message addressed to our domain is subject to archiving and review by persons other than the intended recipient. Thank you. _____________