summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2008-03-04 00:36:39 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2008-03-04 00:36:39 +0000
commitcdc019c4cb32cd1685b06fc6775a0a98fa8fb2e8 (patch)
tree488b658901aa00981d425e128f4f88525306997d
parent44ae13d9a9c95b582d8fcd7a820e307bf8424aac (diff)
Redo serial console configuration logic. Smaller, easier to
understand. Add serial console handling for alpha, macppc, zaurus. No functional change for i386/amd64. All archs should now have automatic serial console configuration. ok deraadt@
-rw-r--r--distrib/alpha/common/install.md22
-rw-r--r--distrib/amd64/common/install.md16
-rw-r--r--distrib/armish/ramdisk/install.md5
-rw-r--r--distrib/hp300/ramdisk/install.md5
-rw-r--r--distrib/hppa/install.md5
-rw-r--r--distrib/i386/common/install.md16
-rw-r--r--distrib/landisk/ramdisk/install.md5
-rw-r--r--distrib/luna88k/ramdisk/install.md5
-rw-r--r--distrib/mac68k/ramdisk/install.md5
-rw-r--r--distrib/macppc/ramdisk/install.md17
-rw-r--r--distrib/miniroot/install.sub76
-rw-r--r--distrib/mvme68k/ramdisk/install.md5
-rw-r--r--distrib/mvme88k/ramdisk/install.md5
-rw-r--r--distrib/mvmeppc/ramdisk/install.md5
-rw-r--r--distrib/sgi/ramdisk/install.md5
-rw-r--r--distrib/sparc/install.md5
-rw-r--r--distrib/sparc64/common/install.md5
-rw-r--r--distrib/vax/install.md5
-rw-r--r--distrib/zaurus/ramdisk/install.md14
19 files changed, 153 insertions, 73 deletions
diff --git a/distrib/alpha/common/install.md b/distrib/alpha/common/install.md
index b3421357a66..afe5b5a5f7c 100644
--- a/distrib/alpha/common/install.md
+++ b/distrib/alpha/common/install.md
@@ -1,4 +1,4 @@
-# $OpenBSD: install.md,v 1.21 2005/10/10 19:22:19 martin Exp $
+# $OpenBSD: install.md,v 1.22 2008/03/04 00:36:38 krw Exp $
#
# Copyright (c) 1996 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -85,3 +85,23 @@ md_prep_disklabel() {
md_congrats() {
}
+
+md_consoleinfo() {
+ local _d _u
+ integer i=0
+
+ # Set up TTYS array to parallel serial device names _d can assume.
+ TTYS[0]=tty0
+ TTYS[1]=ttyB
+
+ for _d in com scc; do
+ for _u in $(scan_dmesg "/^${_d}\([0-9]\) .*/s//\1/p"); do
+ if [[ $_d$_u == $CONSOLE || -z $CONSOLE ]]; then
+ CDEV=$_d$_u
+ CTTY=${TTYS[i]}$_u
+ return
+ fi
+ done
+ i=i+1
+ done
+}
diff --git a/distrib/amd64/common/install.md b/distrib/amd64/common/install.md
index 0a5cd543b2a..9e35a246fb1 100644
--- a/distrib/amd64/common/install.md
+++ b/distrib/amd64/common/install.md
@@ -1,4 +1,4 @@
-# $OpenBSD: install.md,v 1.7 2007/02/11 18:59:30 krw Exp $
+# $OpenBSD: install.md,v 1.8 2008/03/04 00:36:38 krw Exp $
#
#
# Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -40,7 +40,6 @@
#
MDXAPERTURE=2
-MDSERIAL="com com tty0"
ARCH=ARCH
md_installboot() {
@@ -128,3 +127,16 @@ __EOT
md_congrats() {
}
+
+md_consoleinfo() {
+ local _u _d=com
+
+ for _u in $(scan_dmesg "/^$_d\([0-9]\) .*/s//\1/p"); do
+ if [[ $_d$_u == $CONSOLE || -z $CONSOLE ]]; then
+ CDEV=$_d$_u
+ CPROM=com$_u
+ CTTY=tty0$_u
+ return
+ fi
+ done
+}
diff --git a/distrib/armish/ramdisk/install.md b/distrib/armish/ramdisk/install.md
index 9e6da7e2ef1..628752634df 100644
--- a/distrib/armish/ramdisk/install.md
+++ b/distrib/armish/ramdisk/install.md
@@ -1,4 +1,4 @@
-# $OpenBSD: install.md,v 1.2 2007/02/11 18:59:30 krw Exp $
+# $OpenBSD: install.md,v 1.3 2008/03/04 00:36:38 krw Exp $
#
#
# Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -122,3 +122,6 @@ __EOT
md_congrats() {
}
+
+md_consoleinfo() {
+}
diff --git a/distrib/hp300/ramdisk/install.md b/distrib/hp300/ramdisk/install.md
index 7fb5fd91099..c214d968581 100644
--- a/distrib/hp300/ramdisk/install.md
+++ b/distrib/hp300/ramdisk/install.md
@@ -1,4 +1,4 @@
-# $OpenBSD: install.md,v 1.43 2008/01/10 18:00:45 miod Exp $
+# $OpenBSD: install.md,v 1.44 2008/03/04 00:36:38 krw Exp $
# $NetBSD: install.md,v 1.1.2.4 1996/08/26 15:45:14 gwr Exp $
#
# Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -79,3 +79,6 @@ md_prep_disklabel() {
md_congrats() {
}
+
+md_consoleinfo() {
+}
diff --git a/distrib/hppa/install.md b/distrib/hppa/install.md
index 346f6964340..359c7137e31 100644
--- a/distrib/hppa/install.md
+++ b/distrib/hppa/install.md
@@ -1,4 +1,4 @@
-# $OpenBSD: install.md,v 1.6 2005/03/27 15:13:49 krw Exp $
+# $OpenBSD: install.md,v 1.7 2008/03/04 00:36:38 krw Exp $
#
# machine dependent section of installation/upgrade script.
#
@@ -41,3 +41,6 @@ md_prep_disklabel() {
md_congrats() {
}
+
+md_consoleinfo() {
+}
diff --git a/distrib/i386/common/install.md b/distrib/i386/common/install.md
index 2dd9eba216e..9ce27ad7d95 100644
--- a/distrib/i386/common/install.md
+++ b/distrib/i386/common/install.md
@@ -1,4 +1,4 @@
-# $OpenBSD: install.md,v 1.29 2007/02/11 18:59:30 krw Exp $
+# $OpenBSD: install.md,v 1.30 2008/03/04 00:36:38 krw Exp $
#
#
# Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -40,7 +40,6 @@
#
MDXAPERTURE=2
-MDSERIAL="pccom com tty0"
ARCH=ARCH
md_installboot() {
@@ -130,3 +129,16 @@ __EOT
md_congrats() {
}
+
+md_consoleinfo () {
+ local _u _d=pccom
+
+ for _u in $(scan_dmesg "/^$_d\([0-9]\) .*/s//\1/p"); do
+ if [[ $_d$_u == $CONSOLE || -z $CONSOLE ]]; then
+ CDEV=$_d$_u
+ CPROM=com$_u
+ CTTY=tty0$_u
+ return
+ fi
+ done
+}
diff --git a/distrib/landisk/ramdisk/install.md b/distrib/landisk/ramdisk/install.md
index 0c6f2e3a8ba..ab4e86d4fd9 100644
--- a/distrib/landisk/ramdisk/install.md
+++ b/distrib/landisk/ramdisk/install.md
@@ -1,4 +1,4 @@
-# $OpenBSD: install.md,v 1.12 2008/01/10 18:00:46 miod Exp $
+# $OpenBSD: install.md,v 1.13 2008/03/04 00:36:38 krw Exp $
#
#
# Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -135,3 +135,6 @@ __EOT
md_congrats() {
}
+
+md_consoleinfo() {
+}
diff --git a/distrib/luna88k/ramdisk/install.md b/distrib/luna88k/ramdisk/install.md
index 3a526c64051..ff93931b7ef 100644
--- a/distrib/luna88k/ramdisk/install.md
+++ b/distrib/luna88k/ramdisk/install.md
@@ -1,4 +1,4 @@
-# $OpenBSD: install.md,v 1.3 2005/03/27 15:13:50 krw Exp $
+# $OpenBSD: install.md,v 1.4 2008/03/04 00:36:38 krw Exp $
# Copyright (c) 1996 The NetBSD Foundation, Inc.
# All rights reserved.
#
@@ -74,3 +74,6 @@ md_prep_disklabel() {
md_congrats() {
}
+
+md_consoleinfo() {
+}
diff --git a/distrib/mac68k/ramdisk/install.md b/distrib/mac68k/ramdisk/install.md
index e91b0bdf6f0..2deb03bc95d 100644
--- a/distrib/mac68k/ramdisk/install.md
+++ b/distrib/mac68k/ramdisk/install.md
@@ -1,4 +1,4 @@
-# $OpenBSD: install.md,v 1.26 2006/03/09 20:49:00 miod Exp $
+# $OpenBSD: install.md,v 1.27 2008/03/04 00:36:38 krw Exp $
#
# Copyright (c) 2002, Miodrag Vallat.
# All rights reserved.
@@ -108,3 +108,6 @@ __EOT
md_congrats() {
}
+
+md_consoleinfo() {
+}
diff --git a/distrib/macppc/ramdisk/install.md b/distrib/macppc/ramdisk/install.md
index e65c56a3426..f198971abf0 100644
--- a/distrib/macppc/ramdisk/install.md
+++ b/distrib/macppc/ramdisk/install.md
@@ -1,4 +1,4 @@
-# $OpenBSD: install.md,v 1.32 2007/08/15 15:33:20 deraadt Exp $
+# $OpenBSD: install.md,v 1.33 2008/03/04 00:36:38 krw Exp $
#
#
# Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -188,3 +188,18 @@ be something like 'boot hd:,ofwboot /bsd'.
__EOT
}
+
+md_consoleinfo() {
+ local _u _d=zstty
+
+ for _u in $(scan_dmesg "/^$_d\([0-9]\) .*/s//\1/p"); do
+ if [[ $_d$_u == $CONSOLE || -z $CONSOLE ]]; then
+ CDEV=$_d$_u
+ : ${CSPEED:=56700}
+ set -- a b c d e f g h i j
+ shift $_u
+ CTTY=tty$1
+ return
+ fi
+ done
+}
diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub
index e9126c6dd89..72d187a4930 100644
--- a/distrib/miniroot/install.sub
+++ b/distrib/miniroot/install.sub
@@ -1,4 +1,4 @@
-# $OpenBSD: install.sub,v 1.424 2008/02/20 17:46:50 miod Exp $
+# $OpenBSD: install.sub,v 1.425 2008/03/04 00:36:38 krw Exp $
# $NetBSD: install.sub,v 1.5.2.8 1996/09/02 23:25:02 pk Exp $
#
# Copyright (c) 1997-2007 Todd Miller, Theo de Raadt, Ken Westerback
@@ -67,6 +67,7 @@
# md_congrats() - display friendly message
# md_installboot() - install boot-blocks on disk
# md_prep_disklabel() - put an OpenBSD disklabel on the disk
+# md_consoleinfo() - set CDEV, CTTY, CSPEED, CPROM
#
# The following variables can be provided if required:
# MDSETS - list of files to add to THESETS
@@ -74,7 +75,6 @@
# MDDKDEVS - '/^[sw]d[0-9][0-9]* /s/ .*//p' assumed if not provided
# MDCDDEVS - '/^cd[0-9][0-9]* /s/ .*//p' assumed if not provided
# MDMTDEVS - '/^[cms]t[0-9][0-9]* /s/ .*//p'
-# MDSERIAL - offer to configure a serial console
# MDXAPERTURE - set machdep.allowaperture=value in sysctl.conf
. install.md
@@ -194,38 +194,6 @@ get_ifdevs() {
| sed -ne 's/^\(.*\):.*/\1/p'
}
-# Get the first (lowest unit #) serial device if any, if MDSERIAL is set.
-#
-# MDSERIAL is of the form
-#
-# "<dmesg device prefix> <boot loader device prefix> <tty device prefix>"
-#
-# So "pccom com tty0" means the dmesg is searched for devices pccom0, pccom1,
-# ... pccom9. If pccom2 is found, then com2 and tty02 are used in serial
-# console configuration via boot.conf commands and /etc/ttys.
-#
-# NOTE: Only single digit serial devices (<dev>0 -> <dev>9) are looked for.
-get_serialdev() {
- local _d _bd _td
-
- [[ -n $MDSERIAL ]] || exit
- set -- $MDSERIAL
- _d=$1
- _bd=$2
- _td=$3
- set -- $(scan_dmesg "/^${_d}\([0-9]\) .*/s//\1/p")
- echo "$_bd$1 $_td$1"
-}
-
-get_console() {
- local _d
-
- # Find '<dev>: console' and extract <dev>.
- _d=$(sed -ne '/^\([^ ]*\): console$/s//\1/p' /var/run/dmesg.boot)
- set -- $MDSERIAL
- [[ ${_d%[0-9]} == $1 ]] && echo "$2${_d##*[a-z]} $3${_d##*[a-z]}"
-}
-
get_drive() {
ask_which "$1" "contains the $MODE media" "$2"
[[ $resp == done ]] && return 1
@@ -1537,7 +1505,7 @@ populateusrlocal() {
}
questions() {
- local _bd _td _sp
+ local _d
ask_yn "Start sshd(8) by default?" yes
if [[ $resp == n ]]; then
@@ -1569,25 +1537,19 @@ server $1
fi
fi
- [[ -z $SERIALDEV ]] && return
- set -- $(get_console)
- if [[ -n $1 && -n $2 ]]; then
- # When installing via a serial console use it and current speed.
- _sp=$(stty speed)
- else
- # Use first serial port and 9600 (i.e. leave _sp unset).
- set -- $SERIALDEV
- fi
- _bd=$1
- _td=$2
- ask_yn "Change the default console to $_bd?"
+ [[ -n $CDEV ]] || return
+ _d=${CPROM:-$CDEV}
+ ask_yn "Change the default console to $_d?"
[[ $resp == n ]] && return
- ask_which "speed" "should $_bd use" "9600 19200 38400 57600 115200" $_sp
+ ask_which "speed" "should $_d use" "9600 19200 38400 57600 115200" \
+ $CSPEED
[[ $resp == done ]] && return
- echo "stty $_bd $resp\nset tty $_bd" >>/mnt/etc/boot.conf
- sed -e "/^${_td}/s/std.9600/std.${resp}/" \
- -e "/^${_td}/s/unknown/vt220 /" \
- -e "/${_td}/s/off/on secure/" /mnt/etc/ttys >/tmp/ttys
+ sed -e "/^$CTTY/s/std.9600/std.${resp}/" \
+ -e "/^$CTTY/s/unknown/vt220 /" \
+ -e "/$CTTY/s/off/on secure/" /mnt/etc/ttys >/tmp/ttys
+
+ [[ -n $CPROM ]] && \
+ echo "stty $CPROM $resp\nset tty $CPROM" >>/mnt/etc/boot.conf
}
finish_up() {
@@ -1675,7 +1637,15 @@ DKDEVS=$(scan_disknames "${MDDKDEVS:-/^[sw]d[0-9][0-9]* /s/ .*//p}")
CDDEVS=$(scan_disknames "${MDCDDEVS:-/^cd[0-9][0-9]* /s/ .*//p}")
MTDEVS=$(scan_dmesg "${MDMTDEVS:-/^[cms]t[0-9][0-9]* /s/ .*//p}")
IFDEVS=$(get_ifdevs)
-SERIALDEV=$(get_serialdev)
+
+CONSOLE=$(scan_dmesg '/^\([^ ]*\).*: console$/s//\1/p')
+CONSOLE=${CONSOLE% }
+[[ -n $CONSOLE ]] && CSPEED=$(stty speed)
+
+# Look for the serial device matching the console. If we are not installing
+# from a serial console, just find the first serial device that could be used
+# as a console. If a suitable device is found, set CDEV, CTTY, CSPEED, CPROM.
+md_consoleinfo
# Selected sets will be installed in the order they are listed in $THESETS.
# Ensure that siteXX.tgz is the *last* set listed so its contents overwrite
diff --git a/distrib/mvme68k/ramdisk/install.md b/distrib/mvme68k/ramdisk/install.md
index 455a16d4404..320fb00f925 100644
--- a/distrib/mvme68k/ramdisk/install.md
+++ b/distrib/mvme68k/ramdisk/install.md
@@ -1,4 +1,4 @@
-# $OpenBSD: install.md,v 1.28 2005/03/27 15:13:50 krw Exp $
+# $OpenBSD: install.md,v 1.29 2008/03/04 00:36:38 krw Exp $
# Copyright (c) 1996 The NetBSD Foundation, Inc.
# All rights reserved.
#
@@ -76,3 +76,6 @@ md_prep_disklabel() {
md_congrats() {
}
+
+md_consoleinfo() {
+}
diff --git a/distrib/mvme88k/ramdisk/install.md b/distrib/mvme88k/ramdisk/install.md
index cbfc2a89e61..0183b80594c 100644
--- a/distrib/mvme88k/ramdisk/install.md
+++ b/distrib/mvme88k/ramdisk/install.md
@@ -1,4 +1,4 @@
-# $OpenBSD: install.md,v 1.24 2005/03/27 15:13:50 krw Exp $
+# $OpenBSD: install.md,v 1.25 2008/03/04 00:36:38 krw Exp $
# Copyright (c) 1996 The NetBSD Foundation, Inc.
# All rights reserved.
#
@@ -76,3 +76,6 @@ md_prep_disklabel() {
md_congrats() {
}
+
+md_consoleinfo() {
+}
diff --git a/distrib/mvmeppc/ramdisk/install.md b/distrib/mvmeppc/ramdisk/install.md
index c25f7e5129b..94dac6a3f0d 100644
--- a/distrib/mvmeppc/ramdisk/install.md
+++ b/distrib/mvmeppc/ramdisk/install.md
@@ -1,4 +1,4 @@
-# $OpenBSD: install.md,v 1.22 2005/03/27 15:26:59 krw Exp $
+# $OpenBSD: install.md,v 1.23 2008/03/04 00:36:38 krw Exp $
#
#
# Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -49,3 +49,6 @@ md_prep_disklabel() {
md_congrats() {
}
+
+md_consoleinfo() {
+}
diff --git a/distrib/sgi/ramdisk/install.md b/distrib/sgi/ramdisk/install.md
index f78430b54ab..ca0886c3f26 100644
--- a/distrib/sgi/ramdisk/install.md
+++ b/distrib/sgi/ramdisk/install.md
@@ -1,4 +1,4 @@
-# $OpenBSD: install.md,v 1.8 2008/02/18 16:08:26 jsing Exp $
+# $OpenBSD: install.md,v 1.9 2008/03/04 00:36:38 krw Exp $
#
#
# Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -181,3 +181,6 @@ refer to the install document.
To reboot the system, just enter 'reboot' at the shell prompt.
__EOT
}
+
+md_consoleinfo() {
+}
diff --git a/distrib/sparc/install.md b/distrib/sparc/install.md
index 3da8e0058b8..55b964f21aa 100644
--- a/distrib/sparc/install.md
+++ b/distrib/sparc/install.md
@@ -1,4 +1,4 @@
-# $OpenBSD: install.md,v 1.52 2005/04/03 19:33:59 krw Exp $
+# $OpenBSD: install.md,v 1.53 2008/03/04 00:36:38 krw Exp $
# $NetBSD: install.md,v 1.3.2.5 1996/08/26 15:45:28 gwr Exp $
#
#
@@ -92,3 +92,6 @@ md_prep_disklabel() {
md_congrats() {
}
+
+md_consoleinfo() {
+}
diff --git a/distrib/sparc64/common/install.md b/distrib/sparc64/common/install.md
index f0b37a55f2e..4c0c94e6ba5 100644
--- a/distrib/sparc64/common/install.md
+++ b/distrib/sparc64/common/install.md
@@ -1,4 +1,4 @@
-# $OpenBSD: install.md,v 1.19 2005/03/27 15:13:50 krw Exp $
+# $OpenBSD: install.md,v 1.20 2008/03/04 00:36:38 krw Exp $
# $NetBSD: install.md,v 1.3.2.5 1996/08/26 15:45:28 gwr Exp $
#
#
@@ -102,3 +102,6 @@ md_prep_disklabel() {
md_congrats() {
}
+
+md_consoleinfo() {
+}
diff --git a/distrib/vax/install.md b/distrib/vax/install.md
index 68a9ed28655..dbfde364527 100644
--- a/distrib/vax/install.md
+++ b/distrib/vax/install.md
@@ -1,4 +1,4 @@
-# $OpenBSD: install.md,v 1.25 2007/05/28 02:57:11 krw Exp $
+# $OpenBSD: install.md,v 1.26 2008/03/04 00:36:38 krw Exp $
# $NetBSD: install.md,v 1.3.2.5 1996/08/26 15:45:28 gwr Exp $
#
#
@@ -81,3 +81,6 @@ md_prep_disklabel() {
md_congrats() {
}
+
+md_consoleinfo() {
+}
diff --git a/distrib/zaurus/ramdisk/install.md b/distrib/zaurus/ramdisk/install.md
index 04ff7f39117..3f8773eb481 100644
--- a/distrib/zaurus/ramdisk/install.md
+++ b/distrib/zaurus/ramdisk/install.md
@@ -1,4 +1,4 @@
-# $OpenBSD: install.md,v 1.12 2007/05/31 20:28:23 robert Exp $
+# $OpenBSD: install.md,v 1.13 2008/03/04 00:36:38 krw Exp $
#
#
# Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -134,3 +134,15 @@ md_congrats() {
;;
esac
}
+
+md_consoleinfo() {
+ local _u _d=com
+
+ for _u in $(scan_dmesg "/^$_d\([0-9]\) .*/s//\1/p"); do
+ if [[ $_d$_u == $CONSOLE || -z $CONSOLE ]]; then
+ CDEV=$_d$_u
+ CTTY=tty0$_u
+ return
+ fi
+ done
+}