script revision 256340
1245702Snwhitehorn#!/bin/sh
2245702Snwhitehorn#-
3245702Snwhitehorn# Copyright (c) 2013 Nathan Whitehorn
4245702Snwhitehorn# All rights reserved.
5245702Snwhitehorn#
6245702Snwhitehorn# Redistribution and use in source and binary forms, with or without
7245702Snwhitehorn# modification, are permitted provided that the following conditions
8245702Snwhitehorn# are met:
9245702Snwhitehorn# 1. Redistributions of source code must retain the above copyright
10245702Snwhitehorn#    notice, this list of conditions and the following disclaimer.
11245702Snwhitehorn# 2. Redistributions in binary form must reproduce the above copyright
12245702Snwhitehorn#    notice, this list of conditions and the following disclaimer in the
13245702Snwhitehorn#    documentation and/or other materials provided with the distribution.
14245702Snwhitehorn#
15245702Snwhitehorn# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16245702Snwhitehorn# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17245702Snwhitehorn# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18245702Snwhitehorn# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19245702Snwhitehorn# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20245702Snwhitehorn# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21245702Snwhitehorn# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22245702Snwhitehorn# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23245702Snwhitehorn# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24245702Snwhitehorn# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25245702Snwhitehorn# SUCH DAMAGE.
26245702Snwhitehorn#
27245702Snwhitehorn# $FreeBSD: stable/10/usr.sbin/bsdinstall/scripts/script 256340 2013-10-11 20:28:30Z des $
28245702Snwhitehorn
29245702Snwhitehorn# VARIABLES:
30245702Snwhitehorn# PARTITIONS
31245702Snwhitehorn# DISTRIBUTIONS
32245702Snwhitehorn# BSDINSTALL_DISTDIR
33245702Snwhitehorn
34245702Snwhitehornerror() {
35245702Snwhitehorn	test -f $PATH_FSTAB && bsdinstall umount
36245702Snwhitehorn	echo "Installation Error!"
37245702Snwhitehorn	cat $BSDINSTALL_LOG
38245702Snwhitehorn	echo "Installation Error!"
39245702Snwhitehorn	exit 1
40245702Snwhitehorn}
41245702Snwhitehorn
42245702Snwhitehornset -e
43245702Snwhitehorntrap error EXIT
44245702Snwhitehorn
45245702SnwhitehornSCRIPT="$1"
46245702Snwhitehornshift
47245702Snwhitehorn
48245702Snwhitehornecho "Begun Installation at $(date)" > $BSDINSTALL_LOG
49245702Snwhitehornrm -rf $BSDINSTALL_TMPETC
50245702Snwhitehornmkdir $BSDINSTALL_TMPETC
51245702Snwhitehorn
52245702Snwhitehornsplit -a 2 -p '^#!.*' "$SCRIPT" /tmp/bsdinstall-installscript-
53245702Snwhitehorn
54245707Snwhitehorn. /tmp/bsdinstall-installscript-aa
55245702Snwhitehorn: ${DISTRIBUTIONS="kernel.txz base.txz"}; export DISTRIBUTIONS
56245702Snwhitehornexport BSDINSTALL_DISTDIR
57245702Snwhitehorn
58245702Snwhitehorn# Make partitions
59245702Snwhitehornrm -f $PATH_FSTAB
60245702Snwhitehorntouch $PATH_FSTAB
61245702Snwhitehornbsdinstall scriptedpart "$PARTITIONS"
62245702Snwhitehornbsdinstall mount
63245702Snwhitehorn
64245702Snwhitehorn# Unpack distributions
65245702Snwhitehornbsdinstall checksum
66245702Snwhitehornbsdinstall distextract
67245702Snwhitehorn
68245702Snwhitehorn# Finalize install
69245702Snwhitehornbsdinstall config
70245702Snwhitehorn
71246013Snwhitehorn# Make sure networking is functional, if we can arrange that
72246013Snwhitehornif [ ! -f $BSDINSTALL_CHROOT/etc/resolv.conf -a -f /etc/resolv.conf ]; then
73246013Snwhitehorn	cp /etc/resolv.conf $BSDINSTALL_CHROOT/etc/resolv.conf
74246013Snwhitehornfi
75246013Snwhitehorn
76245702Snwhitehorn# Run post-install script
77245702Snwhitehornif [ -f /tmp/bsdinstall-installscript-ab ]; then
78245702Snwhitehorn	cp /tmp/bsdinstall-installscript-ab $BSDINSTALL_CHROOT/tmp/installscript
79245702Snwhitehorn	chmod a+x $BSDINSTALL_CHROOT/tmp/installscript
80245702Snwhitehorn	mount -t devfs devfs "$BSDINSTALL_CHROOT/dev"
81245702Snwhitehorn	chroot $BSDINSTALL_CHROOT /tmp/installscript $@ 2>&1
82245702Snwhitehorn	umount "$BSDINSTALL_CHROOT/dev"
83245702Snwhitehorn	rm $BSDINSTALL_CHROOT/tmp/installscript
84245702Snwhitehornfi
85245702Snwhitehorn
86256340Sdesbsdinstall entropy
87245702Snwhitehornbsdinstall umount
88245702Snwhitehorn
89245702Snwhitehornecho "Installation Completed at $(date)" >> $BSDINSTALL_LOG
90245702Snwhitehorn
91245702Snwhitehorntrap true EXIT
92