140682Snsouch#!/bin/sh 240682Snsouch#- 340682Snsouch# Copyright (c) 2011 Nathan Whitehorn 440682Snsouch# Copyright (c) 2013 Devin Teske 540682Snsouch# All rights reserved. 640682Snsouch# 740682Snsouch# Redistribution and use in source and binary forms, with or without 840682Snsouch# modification, are permitted provided that the following conditions 940682Snsouch# are met: 1040682Snsouch# 1. Redistributions of source code must retain the above copyright 1140682Snsouch# notice, this list of conditions and the following disclaimer. 1240682Snsouch# 2. Redistributions in binary form must reproduce the above copyright 1340682Snsouch# notice, this list of conditions and the following disclaimer in the 1440682Snsouch# documentation and/or other materials provided with the distribution. 1540682Snsouch# 1640682Snsouch# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1740682Snsouch# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1840682Snsouch# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1940682Snsouch# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2040682Snsouch# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2140682Snsouch# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2240682Snsouch# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2340682Snsouch# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2440682Snsouch# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2550476Speter# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2640682Snsouch# SUCH DAMAGE. 27276278Sian# 2840682Snsouch# $FreeBSD$ 2979538Sru# 3040682Snsouch############################################################ INCLUDES 3140682Snsouch 3275670Sru# Delay processing of debug flags as the parent until MAIN. export'd to disable 3340682Snsouch# re-processing of flags (all children log to the parent's log file). 3456460Sasmodai# 3556460Sasmodaiexport DEBUG_SELF_INITIALIZE= 3640682Snsouchexport DEBUG_INITIALIZE_FILE= 3756460Sasmodai 3856460SasmodaiBSDCFG_SHARE="/usr/share/bsdconfig" 3956460Sasmodai. $BSDCFG_SHARE/common.subr || exit 1 4040682Snsouch 4140682Snsouch############################################################ GLOBALS 4240682Snsouch 4340682Snsouch: ${BSDINSTALL_TMPETC="/tmp/bsdinstall_etc"}; export BSDINSTALL_TMPETC 4440682Snsouch: ${BSDINSTALL_TMPBOOT="/tmp/bsdinstall_boot"}; export BSDINSTALL_TMPBOOT 4540682Snsouch: ${PATH_FSTAB="$BSDINSTALL_TMPETC/fstab"}; export PATH_FSTAB 4640682Snsouch: ${BSDINSTALL_DISTDIR="/usr/freebsd-dist"}; export BSDINSTALL_DISTDIR 4757676Ssheldonh: ${BSDINSTALL_CHROOT="/mnt"}; export BSDINSTALL_CHROOT 4857676Ssheldonh 4957676Ssheldonhexport debugFile="${debugFile-${BSDINSTALL_LOG-/tmp/bsdinstall_log}}" 50141851Sru 5140682Snsouch############################################################ MAIN 5240682Snsouch 5340682Snsouch# 5457676Ssheldonh# Process command-line arguments 5557676Ssheldonh# 5640682Snsouchwhile getopts $GETOPTS_STDARGS ignored; do 5770466Sru : just skipping known flags 5840682Snsouchdone 5957676Ssheldonhshift $(( $OPTIND - 1 )) 6057676Ssheldonh 6168881Sben# What are we here to do? 6240682SnsouchVERB="${1:-auto}"; shift 6357676Ssheldonh 6457676Ssheldonh[ -d "$BSDINSTALL_TMPETC" ] || mkdir -p "$BSDINSTALL_TMPETC" 6568881Sben[ -d "$BSDINSTALL_TMPBOOT" ] || mkdir -p "$BSDINSTALL_TMPBOOT" 6670466Sru 6757676Ssheldonh# Only enable debugging if debugFile is non-NULL and can be initialized 6857676Ssheldonhf_quietly f_debug_init 6940682Snsouchf_isset debugFile || debug= 7057676Ssheldonh 7157676Ssheldonhf_dprintf "Running installation step: %s %s" "$VERB" "$*" 7257676Ssheldonhif [ "$debug" ]; then 7357676Ssheldonh case "$debugFile" in 7440682Snsouch # If NULL, send errors to the bit-bucket 7540682Snsouch "") exec "/usr/libexec/bsdinstall/$VERB" "$@" 2> /dev/null ;; 7640682Snsouch # If begins with `+', send errors to both terminal and file (no `+') 7740682Snsouch +*) exec "/usr/libexec/bsdinstall/$VERB" "$@" \ 7840682Snsouch 2>&1 >&$TERMINAL_STDOUT_PASSTHRU | tee "${debugFile#+}" ;; 7940682Snsouch # Otherwise, just send errors to the file specified 8040682Snsouch *) exec "/usr/libexec/bsdinstall/$VERB" "$@" 2>> "$debugFile" 8140682Snsouch esac 8240682Snsouchelse 8340682Snsouch exec "/usr/libexec/bsdinstall/$VERB" "$@" 2> /dev/null 8440682Snsouchfi 8540682Snsouch 8657676Ssheldonh################################################################################ 8757676Ssheldonh# END 8840682Snsouch################################################################################ 8957676Ssheldonh