12ffbec18SNathan Whitehorn#!/bin/sh 22ffbec18SNathan Whitehorn#- 32ffbec18SNathan Whitehorn# Copyright (c) 2013 Nathan Whitehorn 4bc4a673fSDevin Teske# Copyright (c) 2013 Devin Teske 52ffbec18SNathan Whitehorn# All rights reserved. 62ffbec18SNathan Whitehorn# 72ffbec18SNathan Whitehorn# Redistribution and use in source and binary forms, with or without 82ffbec18SNathan Whitehorn# modification, are permitted provided that the following conditions 92ffbec18SNathan Whitehorn# are met: 102ffbec18SNathan Whitehorn# 1. Redistributions of source code must retain the above copyright 112ffbec18SNathan Whitehorn# notice, this list of conditions and the following disclaimer. 122ffbec18SNathan Whitehorn# 2. Redistributions in binary form must reproduce the above copyright 132ffbec18SNathan Whitehorn# notice, this list of conditions and the following disclaimer in the 142ffbec18SNathan Whitehorn# documentation and/or other materials provided with the distribution. 152ffbec18SNathan Whitehorn# 162ffbec18SNathan Whitehorn# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 172ffbec18SNathan Whitehorn# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 182ffbec18SNathan Whitehorn# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 192ffbec18SNathan Whitehorn# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 202ffbec18SNathan Whitehorn# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 212ffbec18SNathan Whitehorn# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 222ffbec18SNathan Whitehorn# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 232ffbec18SNathan Whitehorn# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 242ffbec18SNathan Whitehorn# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 252ffbec18SNathan Whitehorn# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 262ffbec18SNathan Whitehorn# SUCH DAMAGE. 272ffbec18SNathan Whitehorn# 282ffbec18SNathan Whitehorn# $FreeBSD$ 29bc4a673fSDevin Teske# 30bc4a673fSDevin Teske############################################################ INCLUDES 31bc4a673fSDevin Teske 32bc4a673fSDevin TeskeBSDCFG_SHARE="/usr/share/bsdconfig" 33bc4a673fSDevin Teske. $BSDCFG_SHARE/common.subr || exit 1 34bc4a673fSDevin Teskef_dprintf "%s: loading includes..." "$0" 35bc4a673fSDevin Teskef_include $BSDCFG_SHARE/dialog.subr 36bc4a673fSDevin Teskef_include $BSDCFG_SHARE/variable.subr 37bc4a673fSDevin Teske 38bc4a673fSDevin Teske############################################################ CONFIGURATION 392ffbec18SNathan Whitehorn 402ffbec18SNathan Whitehorn# VARIABLES: 412ffbec18SNathan Whitehorn# PARTITIONS 422ffbec18SNathan Whitehorn# DISTRIBUTIONS 432ffbec18SNathan Whitehorn# BSDINSTALL_DISTDIR 442ffbec18SNathan Whitehorn 45bc4a673fSDevin Teske############################################################ GLOBALS 46bc4a673fSDevin Teske 47bc4a673fSDevin Teske# 48bc4a673fSDevin Teske# Strings that should be moved to an i18n file and loaded with f_include_lang() 49bc4a673fSDevin Teske# 50bc4a673fSDevin Teskemsg_installation_error="Installation Error!" 51bc4a673fSDevin Teske 52bc4a673fSDevin Teske############################################################ FUNCTIONS 53bc4a673fSDevin Teske 54bc4a673fSDevin Teskeerror() 55bc4a673fSDevin Teske{ 56bc4a673fSDevin Teske [ -f "$PATH_FSTAB" ] && bsdinstall umount 57bc4a673fSDevin Teske 58bc4a673fSDevin Teske local file 59bc4a673fSDevin Teske f_getvar "$VAR_DEBUG_FILE#+" file 60bc4a673fSDevin Teske if [ "$file" ]; then 61bc4a673fSDevin Teske f_dialog_title "$msg_installation_error" 62bc4a673fSDevin Teske f_dialog_textbox "$file" 63bc4a673fSDevin Teske # No need to restore title, pining for the fjords 64bc4a673fSDevin Teske fi 65bc4a673fSDevin Teske 662ffbec18SNathan Whitehorn exit 1 672ffbec18SNathan Whitehorn} 682ffbec18SNathan Whitehorn 69bc4a673fSDevin Teske############################################################ MAIN 70bc4a673fSDevin Teske 712ffbec18SNathan Whitehornset -e 722ffbec18SNathan Whitehorntrap error EXIT 732ffbec18SNathan Whitehorn 742ffbec18SNathan WhitehornSCRIPT="$1" 752ffbec18SNathan Whitehornshift 762ffbec18SNathan Whitehorn 774c5d7fabSDevin Teskef_dprintf "Began Installation at %s" "$( date )" 782ffbec18SNathan Whitehornrm -rf $BSDINSTALL_TMPETC 792ffbec18SNathan Whitehornmkdir $BSDINSTALL_TMPETC 802ffbec18SNathan Whitehorn 812ffbec18SNathan Whitehornsplit -a 2 -p '^#!.*' "$SCRIPT" /tmp/bsdinstall-installscript- 822ffbec18SNathan Whitehorn 83bd67b82bSNathan Whitehorn. /tmp/bsdinstall-installscript-aa 842ffbec18SNathan Whitehorn: ${DISTRIBUTIONS="kernel.txz base.txz"}; export DISTRIBUTIONS 852ffbec18SNathan Whitehornexport BSDINSTALL_DISTDIR 862ffbec18SNathan Whitehorn 87bc4a673fSDevin Teske# Re-initialize a new log if preamble changed BSDINSTALL_LOG 88bc4a673fSDevin Teskeif [ "$BSDINSTALL_LOG" != "${debugFile#+}" ]; then 89bc4a673fSDevin Teske export debugFile="$BSDINSTALL_LOG" 90bc4a673fSDevin Teske f_quietly f_debug_init 91bc4a673fSDevin Teske # NB: Being scripted, let debug go to terminal for invalid debugFile 92bc4a673fSDevin Teske f_dprintf "Began Instalation at %s" "$( date )" 93bc4a673fSDevin Teskefi 94bc4a673fSDevin Teske 952ffbec18SNathan Whitehorn# Make partitions 962ffbec18SNathan Whitehornrm -f $PATH_FSTAB 972ffbec18SNathan Whitehorntouch $PATH_FSTAB 98c7684efdSDevin Teskeif [ "$ZFSBOOT_DISKS" ]; then 99c7684efdSDevin Teske bsdinstall zfsboot 100c7684efdSDevin Teskeelse 1012ffbec18SNathan Whitehorn bsdinstall scriptedpart "$PARTITIONS" 102c7684efdSDevin Teskefi 1032ffbec18SNathan Whitehornbsdinstall mount 1042ffbec18SNathan Whitehorn 1052ffbec18SNathan Whitehorn# Unpack distributions 1062ffbec18SNathan Whitehornbsdinstall checksum 1072ffbec18SNathan Whitehornbsdinstall distextract 1082ffbec18SNathan Whitehorn 1092ffbec18SNathan Whitehorn# Finalize install 1102ffbec18SNathan Whitehornbsdinstall config 1112ffbec18SNathan Whitehorn 1124bdf7393SNathan Whitehorn# Make sure networking is functional, if we can arrange that 1134bdf7393SNathan Whitehornif [ ! -f $BSDINSTALL_CHROOT/etc/resolv.conf -a -f /etc/resolv.conf ]; then 1144bdf7393SNathan Whitehorn cp /etc/resolv.conf $BSDINSTALL_CHROOT/etc/resolv.conf 1154bdf7393SNathan Whitehornfi 1164bdf7393SNathan Whitehorn 1172ffbec18SNathan Whitehorn# Run post-install script 1182ffbec18SNathan Whitehornif [ -f /tmp/bsdinstall-installscript-ab ]; then 1192ffbec18SNathan Whitehorn cp /tmp/bsdinstall-installscript-ab $BSDINSTALL_CHROOT/tmp/installscript 1202ffbec18SNathan Whitehorn chmod a+x $BSDINSTALL_CHROOT/tmp/installscript 1212ffbec18SNathan Whitehorn mount -t devfs devfs "$BSDINSTALL_CHROOT/dev" 1222ffbec18SNathan Whitehorn chroot $BSDINSTALL_CHROOT /tmp/installscript $@ 2>&1 1232ffbec18SNathan Whitehorn umount "$BSDINSTALL_CHROOT/dev" 1242ffbec18SNathan Whitehorn rm $BSDINSTALL_CHROOT/tmp/installscript 1252ffbec18SNathan Whitehornfi 1262ffbec18SNathan Whitehorn 127dfc23ba5SDag-Erling Smørgravbsdinstall entropy 1282ffbec18SNathan Whitehornbsdinstall umount 1292ffbec18SNathan Whitehorn 130bc4a673fSDevin Teskef_dprintf "Installation Completed at %s" "$( date )" 1312ffbec18SNathan Whitehorn 132*96eeaba5SDevin Tesketrap - EXIT 133*96eeaba5SDevin Teskeexit $SUCCESS 134bc4a673fSDevin Teske 135bc4a673fSDevin Teske################################################################################ 136bc4a673fSDevin Teske# END 137bc4a673fSDevin Teske################################################################################ 138