On the topic of local tweaks to autoinstall, I was trying to use it for a bunch of blades with very limited disk the other day, and I really wanted to make them just create a single slice for / and some swap.

I ended up doing:

--- a/distrib/amd64/common/install.md
+++ b/distrib/amd64/common/install.md
@@ -125,7 +125,11 @@ start of the disk, NOT the start of the OpenBSD MBR partition.

 __EOT

-       disklabel $FSTABFLAG $_f -E $_disk
+       if _autorespond "disklabel" "$_def"; then
+               print "$resp" | disklabel $FSTABFLAG $_f -E $_disk
+       else
+               disklabel $FSTABFLAG $_f -E $_disk
+       fi
 }

 md_congrats() {


So that then I could put

Use (W)hole disk, use the = W
Use (A)uto layout, (E)dit auto layout, or create (C)ustom layout = C
disklabel = D\na b\n\n4g\n\na a\n\n\n\n/\np\nq\n

in my install.conf

Would you be interested in a patch to add this on all the platforms? Or some other nicer way of doing it? (should it be "Disklabel" rather than little d, for consistency?)



On 06/04/15 23:48, Nathanael Rensen wrote:
A couple of autoinstall(8) tweaks that I find useful.

I find it convenient to be able to specify a path to the response file.
I also prefer to use the DHCP supplied hostname rather than the MAC
address.

Index: install.sub
===================================================================
RCS file: /cvs/src/distrib/miniroot/install.sub,v
retrieving revision 1.829
diff -u -p -r1.829 install.sub
--- install.sub 5 Apr 2015 12:37:14 -0000       1.829
+++ install.sub 6 Apr 2015 13:33:02 -0000
@@ -304,7 +304,7 @@ retrap() {

  # Fetch response file for autoinstall.
  get_responsefile() {
-       local _rf _ifdev _mac _mode _server _lf
+       local _rf _ifdev _mac _mode _server _lf _path
        action=

        [[ -f /auto_upgrade.conf ]] && _rf=/auto_upgrade.conf _mode=upgrade
@@ -328,16 +328,18 @@ get_responsefile() {
                [[ -n $_ifdev ]] && dhclient $_ifdev || break
                _lf=/var/db/dhclient.leases.$_ifdev
                _server=$(sed "/^ *next-server /!d;s///;s/;$//;q" $_lf)
-               _mode=$(sed -E '/^ *filename 
"auto_(install|upgrade)";$/!d;s//\1/;q' $_lf)
+               _mode=$(sed -E '/^ *filename 
"(.*\/)?auto_(install|upgrade)";$/!d;s//\2/;q' $_lf)
+               _path=$(sed -E '/^ *filename "(.*\/)[^/]+";$/!d;s//\1/;q' $_lf)
                hostname "$(sed -E '/^ *option host-name "(.*)";$/!d;s//\1/;q' 
$_lf)"
        done

        # Fetch response file if server and mode are known, otherwise tell which
-       # one was missing. First try to fetch mac-mode.conf, then mode.conf.
+       # one was missing. First try to fetch mac-mode.conf, then
+       # hostname-mode.conf, and finally mode.conf.
        if [[ -n $_server && -n $_mode ]]; then
                _mac=$(ifconfig $_ifdev | sed 's/.*lladdr \(.*\)/\1/p;d')
-               for _rf in {$_mac-,}$_mode; do
-                       _url=http://$_server/$_rf.conf
+               for _rf in {$_mac-,$(hostname -s)-,}$_mode; do
+                       _url=http://$_server/$_path$_rf.conf
                        echo "Fetching $_url"
                        if ftp -Vo "/ai.$_mode.conf" "$_url" 2>/dev/null; then
                                action=$_mode
Index: autoinstall.8
===================================================================
RCS file: /cvs/src/share/man/man8/autoinstall.8,v
retrieving revision 1.11
diff -u -p -r1.11 autoinstall.8
--- autoinstall.8       23 Oct 2014 21:33:21 -0000      1.11
+++ autoinstall.8       6 Apr 2015 13:31:22 -0000
@@ -47,22 +47,16 @@ It behaves as if the user selected '(A)u
  always fetches the response file via the netboot interface.
  .Ss Fetching the response file
  .Nm
-uses HTTP to fetch one of the files
-.Pa install.conf
-or
-.Ar MAC_address Ns - Ns Pa install.conf
-for install answers, or one of
-.Pa upgrade.conf
-or
-.Ar MAC_address Ns - Ns Pa upgrade.conf
-for upgrade answers.
-The URL used to fetch the file is constructed from information provided in
-the
+uses HTTP to fetch a response file which provides answers to
+install or upgrade questions.
+The URL used to fetch the response file is constructed from
+information provided in the
  .Xr dhcpd.conf 5
-statements
-.Ic next-server
+.Ic next-server ,
+.Ic filename
  and
-.Ic filename .
+.Ic host-name
+options.
  If the
  .Ar filename
  is
@@ -71,6 +65,7 @@ then the URLs tried are, in order:
  .Sm off
  .Bd -unfilled -offset indent
  .No http:// Ar next-server No / Ar MAC_address No -install.conf
+.No http:// Ar next-server No / Ar host-name No -install.conf
  .No http:// Ar next-server No /install.conf
  .Ed
  .Sm on
@@ -79,7 +74,7 @@ where
  .Ar MAC_address
  is a string of six hex octets separated by colons
  representing the MAC
-address of the interface being used to fetch the files.
+address of the interface being used to fetch the response file.
  .Pp
  If the
  .Ar filename
@@ -89,9 +84,15 @@ the URLs tried are, in order:
  .Sm off
  .Bd -unfilled -offset indent
  .No http:// Ar next-server No / Ar MAC_address No -upgrade.conf
+.No http:// Ar next-server No / Ar host-name No -upgrade.conf
  .No http:// Ar next-server No /upgrade.conf
  .Ed
  .Sm on
+.Pp
+If the
+.Ar filename
+includes a parent directory it will be used as a server relative
+path in the http URL to fetch the response file.
  .Pp
  On architectures where the
  .Ic filename


It's handy for the log to remain on the host as a reference. Sometimes the
email gets lost (e.g. caught in a spam trap).

Index: install.sub
===================================================================
RCS file: /cvs/src/distrib/miniroot/install.sub,v
retrieving revision 1.829
diff -u -p -r1.829 install.sub
--- install.sub 5 Apr 2015 12:37:14 -0000       1.829
+++ install.sub 6 Apr 2015 13:33:02 -0000
@@ -2305,13 +2318,12 @@ elif [[ -z $RESPFILE ]]; then
        if [[ -f /ai.done ]]; then
                # Generate unique filename and let rc.firsttime feed it to
                # whatever mail system we have at hand by then.
-               while _lf=/mnt/var/log/ai.log.$RANDOM && test -e $_lf; do done
+               _lf=/mnt/var/log/$action.$(date +%Y%m%d%H%M%S)
                cp /ai.log $_lf
                chmod 600 $_lf
                _lf=${_lf#/mnt}
                cat <<__EOT >>/mnt/etc/rc.firsttime
-( /usr/bin/mail -s '$(hostname) $action log' root < $_lf &&
-       rm $_lf ) >/dev/null 2>&1 &
+/usr/bin/mail -s '$(hostname) $action log' root < $_lf >/dev/null 2>&1 &
  __EOT
                exec reboot
        else

Nathanael


Reply via email to