12ffbec18SNathan Whitehorn#!/bin/sh
22ffbec18SNathan Whitehorn#-
32ffbec18SNathan Whitehorn# Copyright (c) 2013 Nathan Whitehorn
42ffbec18SNathan Whitehorn# All rights reserved.
52ffbec18SNathan Whitehorn#
62ffbec18SNathan Whitehorn# Redistribution and use in source and binary forms, with or without
72ffbec18SNathan Whitehorn# modification, are permitted provided that the following conditions
82ffbec18SNathan Whitehorn# are met:
92ffbec18SNathan Whitehorn# 1. Redistributions of source code must retain the above copyright
102ffbec18SNathan Whitehorn#    notice, this list of conditions and the following disclaimer.
112ffbec18SNathan Whitehorn# 2. Redistributions in binary form must reproduce the above copyright
122ffbec18SNathan Whitehorn#    notice, this list of conditions and the following disclaimer in the
132ffbec18SNathan Whitehorn#    documentation and/or other materials provided with the distribution.
142ffbec18SNathan Whitehorn#
152ffbec18SNathan Whitehorn# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
162ffbec18SNathan Whitehorn# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
172ffbec18SNathan Whitehorn# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
182ffbec18SNathan Whitehorn# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
192ffbec18SNathan Whitehorn# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
202ffbec18SNathan Whitehorn# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
212ffbec18SNathan Whitehorn# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
222ffbec18SNathan Whitehorn# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
232ffbec18SNathan Whitehorn# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
242ffbec18SNathan Whitehorn# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
252ffbec18SNathan Whitehorn# SUCH DAMAGE.
262ffbec18SNathan Whitehorn#
272ffbec18SNathan Whitehorn# $FreeBSD$
282ffbec18SNathan Whitehorn
292ffbec18SNathan Whitehorn# VARIABLES:
302ffbec18SNathan Whitehorn# PARTITIONS
312ffbec18SNathan Whitehorn# DISTRIBUTIONS
322ffbec18SNathan Whitehorn# BSDINSTALL_DISTDIR
332ffbec18SNathan Whitehorn
342ffbec18SNathan Whitehornerror() {
352ffbec18SNathan Whitehorn	test -f $PATH_FSTAB && bsdinstall umount
362ffbec18SNathan Whitehorn	echo "Installation Error!"
372ffbec18SNathan Whitehorn	cat $BSDINSTALL_LOG
382ffbec18SNathan Whitehorn	echo "Installation Error!"
392ffbec18SNathan Whitehorn	exit 1
402ffbec18SNathan Whitehorn}
412ffbec18SNathan Whitehorn
422ffbec18SNathan Whitehornset -e
432ffbec18SNathan Whitehorntrap error EXIT
442ffbec18SNathan Whitehorn
452ffbec18SNathan WhitehornSCRIPT="$1"
462ffbec18SNathan Whitehornshift
472ffbec18SNathan Whitehorn
482ffbec18SNathan Whitehornecho "Begun Installation at $(date)" > $BSDINSTALL_LOG
492ffbec18SNathan Whitehornrm -rf $BSDINSTALL_TMPETC
502ffbec18SNathan Whitehornmkdir $BSDINSTALL_TMPETC
512ffbec18SNathan Whitehorn
522ffbec18SNathan Whitehornsplit -a 2 -p '^#!.*' "$SCRIPT" /tmp/bsdinstall-installscript-
532ffbec18SNathan Whitehorn
54*bd67b82bSNathan Whitehorn. /tmp/bsdinstall-installscript-aa
552ffbec18SNathan Whitehorn: ${DISTRIBUTIONS="kernel.txz base.txz"}; export DISTRIBUTIONS
562ffbec18SNathan Whitehornexport BSDINSTALL_DISTDIR
572ffbec18SNathan Whitehorn
582ffbec18SNathan Whitehorn# Make partitions
592ffbec18SNathan Whitehornrm -f $PATH_FSTAB
602ffbec18SNathan Whitehorntouch $PATH_FSTAB
612ffbec18SNathan Whitehornbsdinstall scriptedpart "$PARTITIONS"
622ffbec18SNathan Whitehornbsdinstall mount
632ffbec18SNathan Whitehorn
642ffbec18SNathan Whitehorn# Unpack distributions
652ffbec18SNathan Whitehornbsdinstall checksum
662ffbec18SNathan Whitehornbsdinstall distextract
672ffbec18SNathan Whitehorn
682ffbec18SNathan Whitehorn# Finalize install
692ffbec18SNathan Whitehornbsdinstall config
702ffbec18SNathan Whitehorn
712ffbec18SNathan Whitehorn# Run post-install script
722ffbec18SNathan Whitehornif [ -f /tmp/bsdinstall-installscript-ab ]; then
732ffbec18SNathan Whitehorn	cp /tmp/bsdinstall-installscript-ab $BSDINSTALL_CHROOT/tmp/installscript
742ffbec18SNathan Whitehorn	chmod a+x $BSDINSTALL_CHROOT/tmp/installscript
752ffbec18SNathan Whitehorn	mount -t devfs devfs "$BSDINSTALL_CHROOT/dev"
762ffbec18SNathan Whitehorn	chroot $BSDINSTALL_CHROOT /tmp/installscript $@ 2>&1
772ffbec18SNathan Whitehorn	umount "$BSDINSTALL_CHROOT/dev"
782ffbec18SNathan Whitehorn	rm $BSDINSTALL_CHROOT/tmp/installscript
792ffbec18SNathan Whitehornfi
802ffbec18SNathan Whitehorn
812ffbec18SNathan Whitehornbsdinstall umount
822ffbec18SNathan Whitehorn
832ffbec18SNathan Whitehornecho "Installation Completed at $(date)" >> $BSDINSTALL_LOG
842ffbec18SNathan Whitehorn
852ffbec18SNathan Whitehorntrap true EXIT
86