Created
December 2, 2014 22:38
-
-
Save tuxillo/497bd59b3d52cd910949 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/usr.sbin/installer/installer/installer.sh b/usr.sbin/installer/installer/installer.sh | |
index 51af9aa..3e44c7a 100644 | |
--- a/usr.sbin/installer/installer/installer.sh | |
+++ b/usr.sbin/installer/installer/installer.sh | |
@@ -71,7 +71,11 @@ installer_start() | |
pfi_frontend="cursesvty" | |
fi | |
else | |
- pfi_frontend="cursesx11" | |
+ if [ "X$TTY_INST" = "X" ]; then | |
+ pfi_frontend="curseslog" | |
+ else | |
+ pfi_frontend="cursesx11" | |
+ fi | |
fi | |
fi | |
@@ -170,6 +174,53 @@ installer_start() | |
esac | |
} | |
+is_livecd() | |
+{ | |
+ local _ttyv1=$(grep -w "^ttyv1" /etc/ttys) | |
+ local cdmnt=$(mount -t cd9660 | grep 'cd[0-9]' | cut -w -f1) | |
+ | |
+ if [ ! -z "${cdmnt}" -a -z "${_ttyv1}" ]; then | |
+ return 0 # Return success, it's a LiveCD | |
+ else | |
+ return 1 | |
+ fi | |
+} | |
+ | |
+is_vkernel() | |
+{ | |
+ local guestype=$(sysctl -n kern.vmm_guest) | |
+ | |
+ if [ "${guestype}" = "vkernel" ]; then | |
+ return 0 # Return success, it's a vkernel | |
+ else | |
+ return 1 | |
+ fi | |
+} | |
+ | |
+detect_terminal() | |
+{ | |
+ local _ttyv1=$(grep -w "^ttyv1" /etc/ttys) | |
+ local cdmnt=$(mount -t cd9660 | grep 'cd[0-9]' | cut -w -f1) | |
+ local sdir=$1 | |
+ | |
+ # | |
+ # LIVECD variable indicates whether the output should | |
+ # go to a log (curseslog) or a terminal (cursesvty) | |
+ # Note in the case of being run inside a vkernel the | |
+ # output must still go to a log to avoid polluting | |
+ # the only terminal available, which is normally | |
+ # /dev/console or /dev/ttyv0 | |
+ # | |
+ if ! $(is_vkernel); then | |
+ if $(is_livecd); then | |
+ LIVECD=YES | |
+ TTY=/dev/ttyv1 | |
+ fi | |
+ fi | |
+ SOURCE_DIR=${sdir}/ | |
+ TTY={TTY:-$(tty)} | |
+} | |
+ | |
### MAIN ### | |
if [ $# -gt 1 ]; then | |
@@ -177,25 +228,11 @@ if [ $# -gt 1 ]; then | |
exit 1 | |
fi | |
-# Check if we are booted from a LiveCD, DVD etc. ttyv1 isn't configured in | |
-# this case, so use that as a clue for now. Also, we have to use /dev/console | |
-# in vkernels. | |
# | |
-_ttyv1=`grep -w "^ttyv1" /etc/ttys` | |
-if [ "`sysctl -n kern.vmm_guest`" = "vkernel" ]; then | |
- SOURCE_DIR=/ | |
- TTY=/dev/console | |
-elif [ -z "$_ttyv1" ]; then | |
- LIVECD=YES | |
- SOURCE_DIR=/ | |
- TTY=/dev/ttyv1 | |
-elif [ $# = 1 -a -d $1 ]; then | |
- SOURCE_DIR=$1/ | |
- TTY=/dev/`w | awk '{ print $2 }' | tail -n1` | |
-else | |
- SOURCE_DIR=/ | |
- TTY=/dev/`w | awk '{ print $2 }' | tail -n1` | |
-fi | |
+# Check terminal type and try to find out if we're booting | |
+# from the LiveCD. | |
+# | |
+detect_terminal $1 | |
ps auwwwxxx > /tmp/ps.txt | |
if grep -q dfuibe_installer /tmp/ps.txt; then |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment