File:  [DragonFly] / src / nrelease / installer / usr / local / bin / installer
Revision 1.5: download - view: text, annotated - select for diffs
Sun Jul 11 19:36:03 2004 UTC (10 years, 4 months ago) by dillon
Branches: MAIN
CVS tags: HEAD, DragonFly_Snap29Sep2004, DragonFly_Snap13Sep2004, DragonFly_1_0_REL, DragonFly_1_0A_REL
Give the dfui packages a version number (1.0).  Implement serial console
support for the installer.  A terminal type of vt100-color seems to work
the best.

Submitted-by: Chriss Pressey

#!/bin/sh

# installer - start installer frontend and backend as per pfi config.
# $Id: installer,v 1.10 2004/07/11 16:00:01 cpressey Exp $
# $DragonFly: src/nrelease/installer/usr/local/bin/installer,v 1.5 2004/07/11 19:36:03 dillon Exp $

### SUBS ###

background_backend()
{
	RENDEZVOUS=$1
	TRANSPORT=$2
	cp /usr/local/sbin/dfuibe_installer /var/run/dfuibe_installer
	/var/run/dfuibe_installer -r $RENDEZVOUS -t $TRANSPORT >/dev/null 2>&1
	RESULT=$?
	case "$RESULT" in
	0)
		;;
	5)
		shutdown -h now
		;;
	*)
		;;
	esac
}

installer_start()
{
	# Console start sequence:
	# - Backend (and all other logging) goes to console (ttyv0)
	# - curses frontend starts on ttyv1.
	# - Uses vidcontrol -s 2 to switch to ttyv1 once the frontend is up.

	echo -n "Starting installer.  "

	if [ -r /etc/defaults/pfi.conf ]; then
		. /etc/defaults/pfi.conf
	fi

	if [ -r /etc/pfi.conf ]; then
		echo "Reading /etc/pfi.conf ..."
		. /etc/pfi.conf
	else
		echo "/etc/pfi.conf not found, starting interactive install."
	fi

	# We can set up any install variables and such
	# here by examining pfi_* variables.

	if [ "X$pfi_run" != "X" ]; then
		pfi_frontend=none
		$pfi_run
	fi

	case "X$pfi_dfui_transport" in
	Xcaps)
		sysctl kern.caps_enabled=1
		RENDEZVOUS="installer"
		;;
	Xnpipe)
		RENDEZVOUS="installer"
		;;
	Xtcp)
		RENDEZVOUS="9999"
		;;
	*)
		echo "Unsupported DFUI transport '$pfi_dfui_transport'."
		return
		;;
	esac

	if [ "X$SERIAL" = "XYES" ]; then
		background_backend $RENDEZVOUS $pfi_dfui_transport &
		sleep 1
		/usr/local/sbin/dfuife_curses -r $RENDEZVOUS \
		    -t $pfi_dfui_transport \
		    -b /usr/local/share/dfuife_curses/fred.txt \
		    2>/dev/null
		pfi_frontend=none
	fi

	case "X$pfi_frontend" in
	Xcgi)
		cp /usr/local/sbin/dfuibe_installer /var/run/dfuibe_installer
		/var/run/dfuibe_installer -r test -t $pfi_dfui_transport
		RESULT=$?
		;;
	Xcurses)
		ps auwwwxxx > /tmp/ps.txt
		if grep -q dfuife_curses /tmp/ps.txt; then
			# Frontend is already running.
		else
			/usr/local/sbin/dfuife_curses -r $RENDEZVOUS \
			    -t $pfi_dfui_transport \
			    -b /usr/local/share/dfuife_curses/fred.txt \
			    2>/dev/ttyv0 </dev/ttyv1 >/dev/ttyv1 &
		fi
		rm -f /tmp/ps.txt
		sleep 1
		vidcontrol -s 2
		cp /usr/local/sbin/dfuibe_installer /var/run/dfuibe_installer
		/var/run/dfuibe_installer -r $RENDEZVOUS -t $pfi_dfui_transport
		RESULT=$?
		sleep 1
		killall dfuife_curses
		vidcontrol -s 1
		;;
	Xnone)
		RESULT=0
		;;
	*)
		echo "Unknown installer frontend '$pfi_frontend'."
		return
		;;
	esac

	case "$RESULT" in
	0)
		;;
	5)
		shutdown -h now
		;;
	*)
		;;
	esac
}

### MAIN ###

if [ "X$1" = "Xserial" ]; then
	SERIAL=YES
fi

TTY=`w | awk '{ print $2 }' | tail -n1`
if [ "tty$TTY" = "ttyd0" ]; then
	SERIAL=YES
fi

ps auwwwxxx > /tmp/ps.txt
if grep -q dfuibe_installer /tmp/ps.txt; then
	# Installer is already running. Log in normally.
	rm -f /tmp/ps.txt
else
	rm -f /tmp/ps.txt
	installer_start
fi

### END of installer ###