installer: Make it possible to start the installer from a running system.
authorSascha Wildner <saw@online.de>
Wed, 17 Apr 2013 20:57:04 +0000 (22:57 +0200)
committerSascha Wildner <saw@online.de>
Wed, 17 Apr 2013 20:57:30 +0000 (22:57 +0200)
Also clean up a little and add a small manual page.

Note that the installer isn't hooked into the normal build/install per
this commit. These changes are mainly to help with testing and debugging.

usr.sbin/installer/installer/Makefile
usr.sbin/installer/installer/installer.8 [new file with mode: 0644]
usr.sbin/installer/installer/installer.sh

index a5a9a89..7db7d1a 100644 (file)
@@ -1,4 +1,4 @@
 SCRIPTS=installer.sh
-NOMAN=
+MAN=   installer.8
 
 .include <bsd.prog.mk>
diff --git a/usr.sbin/installer/installer/installer.8 b/usr.sbin/installer/installer/installer.8
new file mode 100644 (file)
index 0000000..40456b0
--- /dev/null
@@ -0,0 +1,58 @@
+.\"
+.\" Copyright (c) 2013
+.\"    The DragonFly Project.  All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\"
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in
+.\"    the documentation and/or other materials provided with the
+.\"    distribution.
+.\" 3. Neither the name of The DragonFly Project nor the names of its
+.\"    contributors may be used to endorse or promote products derived
+.\"    from this software without specific, prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+.\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+.\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+.\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
+.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.Dd April 17, 2013
+.Dt INSTALLER 8
+.Os
+.Sh NAME
+.Nm installer
+.Nd DragonFly installer
+.Sh SYNOPSIS
+.Nm
+.Op Ar source_directory
+.Sh DESCRIPTION
+The
+.Nm
+is an interactive tool to install and configure a
+.Dx
+system.
+Its usage should be self explaining.
+.Pp
+An optional
+.Ar source_directory
+specifies which directory to take as the base directory to copy from.
+If none is specified or when run from the installation media by logging in
+as
+.Sq installer ,
+it defaults to
+.Sq / .
+.\".Sh IMPLEMENTATION NOTES
+.\".Sh HISTORY
index 4cf0682..4ccaeec 100644 (file)
@@ -63,23 +63,15 @@ installer_start()
                ;;
        esac
 
-       if [ "X$SERIAL" = "XYES" ]; then
-               background_backend $RENDEZVOUS $pfi_dfui_transport &
-               sleep 1
-               ESCDELAY=$pfi_curses_escdelay \
-                   /usr/sbin/dfuife_curses \
-                       -r $RENDEZVOUS \
-                       -t $pfi_dfui_transport \
-                       -b /usr/share/installer/fred.txt \
-                   2>/dev/null
-               pfi_frontend=none
-       fi
-
        if [ "X$pfi_frontend" = "Xauto" ]; then
                if [ "X$DISPLAY" = "X" ]; then
-                       pfi_frontend="curses"
+                       if [ "X$LIVECD" = "X" ]; then
+                               pfi_frontend="curseslog"
+                       else
+                               pfi_frontend="cursesvty"
+                       fi
                else
-                       pfi_frontend="xorg"
+                       pfi_frontend="cursesx11"
                fi
        fi
 
@@ -92,7 +84,7 @@ installer_start()
                $pfi_backend -r $RENDEZVOUS -t $pfi_dfui_transport
                RESULT=$?
                ;;
-       Xcurses)
+       Xcursesvty)
                ps auwwwxxx > /tmp/ps.txt
                if grep -q dfuife_curses /tmp/ps.txt; then
                        # Frontend is already running.
@@ -102,18 +94,44 @@ installer_start()
                                -r $RENDEZVOUS \
                                -t $pfi_dfui_transport \
                                -b /usr/share/installer/fred.txt \
-                           2>/dev/ttyv0 </dev/ttyv1 >/dev/ttyv1 &
+                           2>/dev/ttyv0 <$TTY >$TTY &
                fi
                rm -f /tmp/ps.txt
                sleep 1
                vidcontrol -s 2 </dev/ttyv0
-               $pfi_backend -r $RENDEZVOUS -t $pfi_dfui_transport
+               $pfi_backend \
+                   -o $SOURCE_DIR \
+                   -r $RENDEZVOUS \
+                   -t $pfi_dfui_transport
                RESULT=$?
                sleep 1
                killall dfuife_curses
                vidcontrol -s 1 </dev/ttyv0
                ;;
-       Xxorg)
+       Xcurseslog)
+               ps auwwwxxx > /tmp/ps.txt
+               if grep -q dfuife_curses /tmp/ps.txt; then
+                       # Frontend is already running.
+               else
+                       ESCDELAY=$pfi_curses_escdelay \
+                           /usr/sbin/dfuife_curses \
+                               -r $RENDEZVOUS \
+                               -t $pfi_dfui_transport \
+                               -b /usr/share/installer/fred.txt \
+                           2>/tmp/dfuife_curses.log <$TTY >$TTY &
+               fi
+               rm -f /tmp/ps.txt
+               sleep 1
+               $pfi_backend \
+                   -o $SOURCE_DIR \
+                   -r $RENDEZVOUS \
+                   -t $pfi_dfui_transport \
+                   >/dev/null 2>&1
+               RESULT=$?
+               sleep 1
+               killall -q dfuife_curses
+               ;;
+       Xcursesx11)
                ps auwwwxxx > /tmp/ps.txt
                if grep -q dfuife_curses /tmp/ps.txt; then
                        echo "Frontend is already running"
@@ -154,13 +172,25 @@ installer_start()
 
 ### MAIN ###
 
-if [ "X$1" = "Xserial" ]; then
-       SERIAL=YES
+if [ $# -gt 1 ]; then
+       echo "usage: installer [source_directory]"
+       exit 1
 fi
 
-TTY=`w | awk '{ print $2 }' | tail -n1`
-if [ "tty$TTY" = "ttyd0" ]; then
-       SERIAL=YES
+# 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.
+#
+_ttyv1=`grep -w "^ttyv1" /etc/ttys`
+if [ -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
 
 ps auwwwxxx > /tmp/ps.txt