services revision 264472
1190815Srmacklem#!/bin/sh
2190815Srmacklem#-
3190815Srmacklem# Copyright (c) 2011 Nathan Whitehorn
4190815Srmacklem# All rights reserved.
5190815Srmacklem#
6190815Srmacklem# Redistribution and use in source and binary forms, with or without
7190815Srmacklem# modification, are permitted provided that the following conditions
8190815Srmacklem# are met:
9190815Srmacklem# 1. Redistributions of source code must retain the above copyright
10190815Srmacklem#    notice, this list of conditions and the following disclaimer.
11190815Srmacklem# 2. Redistributions in binary form must reproduce the above copyright
12190815Srmacklem#    notice, this list of conditions and the following disclaimer in the
13190815Srmacklem#    documentation and/or other materials provided with the distribution.
14190815Srmacklem#
15190815Srmacklem# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16190815Srmacklem# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17190815Srmacklem# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18190815Srmacklem# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19190815Srmacklem# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20190815Srmacklem# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21190815Srmacklem# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22190815Srmacklem# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23190815Srmacklem# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24190815Srmacklem# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25190815Srmacklem# SUCH DAMAGE.
26190815Srmacklem#
27190815Srmacklem# $FreeBSD: stable/10/usr.sbin/bsdinstall/scripts/services 264472 2014-04-14 21:04:58Z dteske $
28190815Srmacklem
29190815Srmacklem: ${DIALOG_OK=0}
30190815Srmacklem
31190815Srmacklemif [ -f $BSDINSTALL_TMPETC/rc.conf.services ]; then
32190815Srmacklem	eval $( sed -e s/YES/on/i -e s/NO/off/i \
33190815Srmacklem		$BSDINSTALL_TMPETC/rc.conf.services )
34190815Srmacklemelse
35190815Srmacklem	# Default service states. Everything is off if not enabled.
36190815Srmacklem	sshd_enable="on"
37190815Srmacklemfi
38190815Srmacklem
39190815Srmacklemecho -n > $BSDINSTALL_TMPETC/rc.conf.services
40190815Srmacklem
41190815Srmacklemexec 3>&1
42190815SrmacklemDAEMONS=$( dialog --backtitle "FreeBSD Installer" \
43190815Srmacklem    --title "System Configuration" --nocancel --separate-output \
44190815Srmacklem    --checklist "Choose the services you would like to be started at boot:" \
45190815Srmacklem    0 0 0 \
46190815Srmacklem	sshd	"Secure shell daemon" ${sshd_enable:-off} \
47190815Srmacklem	moused	"PS/2 mouse pointer on console" ${moused_enable:-off} \
48190815Srmacklem	ntpd	"Synchronize system and network time" ${ntpd_enable:-off} \
49190815Srmacklem	powerd	"Adjust CPU frequency dynamically if supported" \
50190815Srmacklem		${powerd_enable:-off} \
51190815Srmacklem	dumpdev "Enable kernel crash dumps to /var/crash" ${dumpdev:-on} \
52190815Srmacklem2>&1 1>&3 )
53190815Srmacklemexec 3>&-
54190815Srmacklem
55190815Srmacklemhavedump=
56190815Srmacklemfor daemon in $DAEMONS; do
57190815Srmacklem	[ "$daemon" = "dumpdev" ] && havedump=1 continue
58190815Srmacklem	echo ${daemon}_enable=\"YES\" >> $BSDINSTALL_TMPETC/rc.conf.services
59190815Srmacklemdone
60190815Srmacklem
61190815Srmacklemecho '# Set dumpdev to "AUTO" to enable crash dumps, "NO"' \
62190815Srmacklem     'to disable' >> $BSDINSTALL_TMPETC/rc.conf.services
63190815Srmacklemif [ "$havedump" ]; then
64190815Srmacklem	echo dumpdev=\"AUTO\" >> $BSDINSTALL_TMPETC/rc.conf.services
65190815Srmacklemelse
66190815Srmacklem	echo dumpdev=\"NO\" >> $BSDINSTALL_TMPETC/rc.conf.services
67190815Srmacklemfi
68190815Srmacklem