1245702Snwhitehorn#!/bin/sh 2245702Snwhitehorn#- 3245702Snwhitehorn# Copyright (c) 2013 Nathan Whitehorn 4290285Sdteske# Copyright (c) 2013-2015 Devin Teske 5245702Snwhitehorn# All rights reserved. 6245702Snwhitehorn# 7245702Snwhitehorn# Redistribution and use in source and binary forms, with or without 8245702Snwhitehorn# modification, are permitted provided that the following conditions 9245702Snwhitehorn# are met: 10245702Snwhitehorn# 1. Redistributions of source code must retain the above copyright 11245702Snwhitehorn# notice, this list of conditions and the following disclaimer. 12245702Snwhitehorn# 2. Redistributions in binary form must reproduce the above copyright 13245702Snwhitehorn# notice, this list of conditions and the following disclaimer in the 14245702Snwhitehorn# documentation and/or other materials provided with the distribution. 15245702Snwhitehorn# 16245702Snwhitehorn# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17245702Snwhitehorn# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18245702Snwhitehorn# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19245702Snwhitehorn# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20245702Snwhitehorn# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21245702Snwhitehorn# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22245702Snwhitehorn# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23245702Snwhitehorn# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24245702Snwhitehorn# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25245702Snwhitehorn# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26245702Snwhitehorn# SUCH DAMAGE. 27245702Snwhitehorn# 28245702Snwhitehorn# $FreeBSD$ 29258421Sdteske# 30258421Sdteske############################################################ INCLUDES 31245702Snwhitehorn 32258421SdteskeBSDCFG_SHARE="/usr/share/bsdconfig" 33258421Sdteske. $BSDCFG_SHARE/common.subr || exit 1 34258421Sdteskef_dprintf "%s: loading includes..." "$0" 35258421Sdteskef_include $BSDCFG_SHARE/dialog.subr 36258421Sdteskef_include $BSDCFG_SHARE/variable.subr 37258421Sdteske 38258421Sdteske############################################################ CONFIGURATION 39258421Sdteske 40245702Snwhitehorn# VARIABLES: 41245702Snwhitehorn# PARTITIONS 42245702Snwhitehorn# DISTRIBUTIONS 43245702Snwhitehorn# BSDINSTALL_DISTDIR 44245702Snwhitehorn 45258421Sdteske############################################################ GLOBALS 46258421Sdteske 47258421Sdteske# 48258421Sdteske# Strings that should be moved to an i18n file and loaded with f_include_lang() 49258421Sdteske# 50258421Sdteskemsg_installation_error="Installation Error!" 51258421Sdteske 52258421Sdteske############################################################ FUNCTIONS 53258421Sdteske 54258421Sdteskeerror() 55258421Sdteske{ 56258421Sdteske [ -f "$PATH_FSTAB" ] && bsdinstall umount 57258421Sdteske 58258421Sdteske local file 59258421Sdteske f_getvar "$VAR_DEBUG_FILE#+" file 60258421Sdteske if [ "$file" ]; then 61258421Sdteske f_dialog_title "$msg_installation_error" 62258421Sdteske f_dialog_textbox "$file" 63258421Sdteske # No need to restore title, pining for the fjords 64258421Sdteske fi 65258421Sdteske 66245702Snwhitehorn exit 1 67245702Snwhitehorn} 68245702Snwhitehorn 69258421Sdteske############################################################ MAIN 70258421Sdteske 71245702Snwhitehornset -e 72245702Snwhitehorntrap error EXIT 73245702Snwhitehorn 74245702SnwhitehornSCRIPT="$1" 75245702Snwhitehornshift 76245702Snwhitehorn 77264449Sdteskef_dprintf "Began Installation at %s" "$( date )" 78245702Snwhitehornrm -rf $BSDINSTALL_TMPETC 79245702Snwhitehornmkdir $BSDINSTALL_TMPETC 80245702Snwhitehorn 81245702Snwhitehornsplit -a 2 -p '^#!.*' "$SCRIPT" /tmp/bsdinstall-installscript- 82245702Snwhitehorn 83245707Snwhitehorn. /tmp/bsdinstall-installscript-aa 84245702Snwhitehorn: ${DISTRIBUTIONS="kernel.txz base.txz"}; export DISTRIBUTIONS 85245702Snwhitehornexport BSDINSTALL_DISTDIR 86245702Snwhitehorn 87258421Sdteske# Re-initialize a new log if preamble changed BSDINSTALL_LOG 88258421Sdteskeif [ "$BSDINSTALL_LOG" != "${debugFile#+}" ]; then 89258421Sdteske export debugFile="$BSDINSTALL_LOG" 90258421Sdteske f_quietly f_debug_init 91258421Sdteske # NB: Being scripted, let debug go to terminal for invalid debugFile 92258421Sdteske f_dprintf "Began Instalation at %s" "$( date )" 93258421Sdteskefi 94258421Sdteske 95245702Snwhitehorn# Make partitions 96245702Snwhitehornrm -f $PATH_FSTAB 97245702Snwhitehorntouch $PATH_FSTAB 98264472Sdteskeif [ "$ZFSBOOT_DISKS" ]; then 99264472Sdteske bsdinstall zfsboot 100264472Sdteskeelse 101264472Sdteske bsdinstall scriptedpart "$PARTITIONS" 102264472Sdteskefi 103245702Snwhitehornbsdinstall mount 104245702Snwhitehorn 105245702Snwhitehorn# Unpack distributions 106245702Snwhitehornbsdinstall checksum 107245702Snwhitehornbsdinstall distextract 108245702Snwhitehorn 109245702Snwhitehorn# Finalize install 110245702Snwhitehornbsdinstall config 111245702Snwhitehorn 112246013Snwhitehorn# Make sure networking is functional, if we can arrange that 113246013Snwhitehornif [ ! -f $BSDINSTALL_CHROOT/etc/resolv.conf -a -f /etc/resolv.conf ]; then 114246013Snwhitehorn cp /etc/resolv.conf $BSDINSTALL_CHROOT/etc/resolv.conf 115246013Snwhitehornfi 116246013Snwhitehorn 117245702Snwhitehorn# Run post-install script 118245702Snwhitehornif [ -f /tmp/bsdinstall-installscript-ab ]; then 119245702Snwhitehorn cp /tmp/bsdinstall-installscript-ab $BSDINSTALL_CHROOT/tmp/installscript 120245702Snwhitehorn chmod a+x $BSDINSTALL_CHROOT/tmp/installscript 121245702Snwhitehorn mount -t devfs devfs "$BSDINSTALL_CHROOT/dev" 122245702Snwhitehorn chroot $BSDINSTALL_CHROOT /tmp/installscript $@ 2>&1 123245702Snwhitehorn umount "$BSDINSTALL_CHROOT/dev" 124245702Snwhitehorn rm $BSDINSTALL_CHROOT/tmp/installscript 125245702Snwhitehornfi 126245702Snwhitehorn 127256340Sdesbsdinstall entropy 128245702Snwhitehornbsdinstall umount 129245702Snwhitehorn 130258421Sdteskef_dprintf "Installation Completed at %s" "$( date )" 131245702Snwhitehorn 132290286Sdtesketrap - EXIT 133290286Sdteskeexit $SUCCESS 134258421Sdteske 135258421Sdteske################################################################################ 136258421Sdteske# END 137258421Sdteske################################################################################ 138