12ffbec18SNathan Whitehorn#!/bin/sh 22ffbec18SNathan Whitehorn#- 32ffbec18SNathan Whitehorn# Copyright (c) 2013 Nathan Whitehorn 4*bc4a673fSDevin 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$ 29*bc4a673fSDevin Teske# 30*bc4a673fSDevin Teske############################################################ INCLUDES 31*bc4a673fSDevin Teske 32*bc4a673fSDevin TeskeBSDCFG_SHARE="/usr/share/bsdconfig" 33*bc4a673fSDevin Teske. $BSDCFG_SHARE/common.subr || exit 1 34*bc4a673fSDevin Teskef_dprintf "%s: loading includes..." "$0" 35*bc4a673fSDevin Teskef_include $BSDCFG_SHARE/dialog.subr 36*bc4a673fSDevin Teskef_include $BSDCFG_SHARE/variable.subr 37*bc4a673fSDevin Teske 38*bc4a673fSDevin Teske############################################################ CONFIGURATION 392ffbec18SNathan Whitehorn 402ffbec18SNathan Whitehorn# VARIABLES: 412ffbec18SNathan Whitehorn# PARTITIONS 422ffbec18SNathan Whitehorn# DISTRIBUTIONS 432ffbec18SNathan Whitehorn# BSDINSTALL_DISTDIR 442ffbec18SNathan Whitehorn 45*bc4a673fSDevin Teske############################################################ GLOBALS 46*bc4a673fSDevin Teske 47*bc4a673fSDevin Teske# 48*bc4a673fSDevin Teske# Strings that should be moved to an i18n file and loaded with f_include_lang() 49*bc4a673fSDevin Teske# 50*bc4a673fSDevin Teskemsg_installation_error="Installation Error!" 51*bc4a673fSDevin Teske 52*bc4a673fSDevin Teske############################################################ FUNCTIONS 53*bc4a673fSDevin Teske 54*bc4a673fSDevin Teskeerror() 55*bc4a673fSDevin Teske{ 56*bc4a673fSDevin Teske [ -f "$PATH_FSTAB" ] && bsdinstall umount 57*bc4a673fSDevin Teske 58*bc4a673fSDevin Teske local file 59*bc4a673fSDevin Teske f_getvar "$VAR_DEBUG_FILE#+" file 60*bc4a673fSDevin Teske if [ "$file" ]; then 61*bc4a673fSDevin Teske f_dialog_title "$msg_installation_error" 62*bc4a673fSDevin Teske f_dialog_textbox "$file" 63*bc4a673fSDevin Teske # No need to restore title, pining for the fjords 64*bc4a673fSDevin Teske fi 65*bc4a673fSDevin Teske 662ffbec18SNathan Whitehorn exit 1 672ffbec18SNathan Whitehorn} 682ffbec18SNathan Whitehorn 69*bc4a673fSDevin Teske############################################################ MAIN 70*bc4a673fSDevin Teske 712ffbec18SNathan Whitehornset -e 722ffbec18SNathan Whitehorntrap error EXIT 732ffbec18SNathan Whitehorn 742ffbec18SNathan WhitehornSCRIPT="$1" 752ffbec18SNathan Whitehornshift 762ffbec18SNathan Whitehorn 77*bc4a673fSDevin Teskef_dprintf "Began Instalation 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 87*bc4a673fSDevin Teske# Re-initialize a new log if preamble changed BSDINSTALL_LOG 88*bc4a673fSDevin Teskeif [ "$BSDINSTALL_LOG" != "${debugFile#+}" ]; then 89*bc4a673fSDevin Teske export debugFile="$BSDINSTALL_LOG" 90*bc4a673fSDevin Teske f_quietly f_debug_init 91*bc4a673fSDevin Teske # NB: Being scripted, let debug go to terminal for invalid debugFile 92*bc4a673fSDevin Teske f_dprintf "Began Instalation at %s" "$( date )" 93*bc4a673fSDevin Teskefi 94*bc4a673fSDevin Teske 952ffbec18SNathan Whitehorn# Make partitions 962ffbec18SNathan Whitehornrm -f $PATH_FSTAB 972ffbec18SNathan Whitehorntouch $PATH_FSTAB 982ffbec18SNathan Whitehornbsdinstall scriptedpart "$PARTITIONS" 992ffbec18SNathan Whitehornbsdinstall mount 1002ffbec18SNathan Whitehorn 1012ffbec18SNathan Whitehorn# Unpack distributions 1022ffbec18SNathan Whitehornbsdinstall checksum 1032ffbec18SNathan Whitehornbsdinstall distextract 1042ffbec18SNathan Whitehorn 1052ffbec18SNathan Whitehorn# Finalize install 1062ffbec18SNathan Whitehornbsdinstall config 1072ffbec18SNathan Whitehorn 1084bdf7393SNathan Whitehorn# Make sure networking is functional, if we can arrange that 1094bdf7393SNathan Whitehornif [ ! -f $BSDINSTALL_CHROOT/etc/resolv.conf -a -f /etc/resolv.conf ]; then 1104bdf7393SNathan Whitehorn cp /etc/resolv.conf $BSDINSTALL_CHROOT/etc/resolv.conf 1114bdf7393SNathan Whitehornfi 1124bdf7393SNathan Whitehorn 1132ffbec18SNathan Whitehorn# Run post-install script 1142ffbec18SNathan Whitehornif [ -f /tmp/bsdinstall-installscript-ab ]; then 1152ffbec18SNathan Whitehorn cp /tmp/bsdinstall-installscript-ab $BSDINSTALL_CHROOT/tmp/installscript 1162ffbec18SNathan Whitehorn chmod a+x $BSDINSTALL_CHROOT/tmp/installscript 1172ffbec18SNathan Whitehorn mount -t devfs devfs "$BSDINSTALL_CHROOT/dev" 1182ffbec18SNathan Whitehorn chroot $BSDINSTALL_CHROOT /tmp/installscript $@ 2>&1 1192ffbec18SNathan Whitehorn umount "$BSDINSTALL_CHROOT/dev" 1202ffbec18SNathan Whitehorn rm $BSDINSTALL_CHROOT/tmp/installscript 1212ffbec18SNathan Whitehornfi 1222ffbec18SNathan Whitehorn 123dfc23ba5SDag-Erling Smørgravbsdinstall entropy 1242ffbec18SNathan Whitehornbsdinstall umount 1252ffbec18SNathan Whitehorn 126*bc4a673fSDevin Teskef_dprintf "Installation Completed at %s" "$( date )" 1272ffbec18SNathan Whitehorn 1282ffbec18SNathan Whitehorntrap true EXIT 129*bc4a673fSDevin Teske 130*bc4a673fSDevin Teske################################################################################ 131*bc4a673fSDevin Teske# END 132*bc4a673fSDevin Teske################################################################################ 133