docsinstall revision 238438
1161200Ssam#!/bin/sh
2174245Ssam#-
3161200Ssam# Copyright (c) 2012 Devin Teske
4161200Ssam# All Rights Reserved.
5161200Ssam#
6161200Ssam# Redistribution and use in source and binary forms, with or without
7161200Ssam# modification, are permitted provided that the following conditions
8161200Ssam# are met:
9161200Ssam# 1. Redistributions of source code must retain the above copyright
10161200Ssam#    notice, this list of conditions and the following disclaimer.
11161200Ssam# 2. Redistributions in binary form must reproduce the above copyright
12161200Ssam#    notice, this list of conditions and the following disclaimer in the
13161200Ssam#    documentation and/or other materials provided with the distribution.
14161200Ssam#
15161200Ssam# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16161200Ssam# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE
17161200Ssam# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18161200Ssam# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19161200Ssam# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20161200Ssam# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21161200Ssam# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22161200Ssam# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23161200Ssam# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24161200Ssam# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25161200Ssam# SUCH DAMAGE.
26161200Ssam#
27161200Ssam# $FreeBSD: head/usr.sbin/bsdconfig/docsinstall/docsinstall 238438 2012-07-14 03:16:57Z dteske $
28161200Ssam#
29161200Ssam############################################################ INCLUDES
30161200Ssam
31161200SsamBSDCFG_LIBE="/usr/libexec/bsdconfig"
32161200Ssam. $BSDCFG_LIBE/include/common.subr || exit 1
33161200Ssamf_include $BSDCFG_LIBE/include/dialog.subr
34161200Ssamf_include $BSDCFG_LIBE/include/mustberoot.subr
35161200Ssam
36161200SsamAPP_DIR="020.docsinstall"
37161200Ssamf_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
38161200Ssam
39161200Ssamipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
40161200Ssam[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
41161200Ssam
42161200Ssam############################################################ CONFIGURATION
43161200Ssam
44161200Ssam#
45161200Ssam# If X11 is requested, which terminal and what options should we use?
46161200Ssam#
47161200SsamX11TERM=xterm
48161200SsamX11TERM_OPTS=
49161200Ssam
50161200Ssam############################################################ MAIN
51161200Ssam
52161200Ssam# Incorporate rc-file if it exists
53161200Ssam[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
54161200Ssam
55161200Ssam#
56161200Ssam# Process command-line arguments
57161200Ssam#
58161200Ssamwhile getopts hSX flag; do
59161200Ssam	case "$flag" in
60161200Ssam	h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";;
61161200Ssam	esac
62161200Ssamdone
63231863Sadrianshift $(( $OPTIND - 1 ))
64231863Sadrian
65231863Sadrian#
66161200Ssam# Initialize
67161200Ssam#
68161200Ssamf_dialog_init
69161200Ssamf_mustberoot_init
70161200Ssam
71161200Ssam#
72161200Ssam# If Xdialog(1) is requested, we'll need to wrap bsdinstall(8) into xterm(1)
73161200Ssam#
74161200Ssamif [ "$USE_XDIALOG" ]; then
75161200Ssam	#
76161200Ssam	# Make sure $X11TERM exists and is executable
77161200Ssam	#
78161200Ssam	case "$X11TERM" in
79161200Ssam	*/*)
80161200Ssam		[ -e "$X11TERM" ] || f_die 1 \
81161200Ssam			"$msg_no_such_file_or_directory" "$pgm" "$X11TERM"
82161200Ssam		[ -x "$X11TERM" ] || f_die 1 \
83161200Ssam			"$msg_permission_denied" "$pgm" "$X11TERM"
84161200Ssam		;;
85161200Ssam	*)
86161200Ssam		f_have "$X11TERM" || f_die 1 \
87161200Ssam			"$msg_no_such_file_or_directory" "$pgm" "$X11TERM"
88161200Ssam	esac
89161200Ssam
90161200Ssam	exec $X11TERM $X11TERM_OPTS -e /usr/sbin/bsdinstall docsinstall
91161200Ssamelse
92161200Ssam	exec /usr/sbin/bsdinstall docsinstall
93161200Ssamfi
94231863Sadrian
95231863Sadrian################################################################################
96161200Ssam# END
97161200Ssam################################################################################
98231863Sadrian