xref: /freebsd/usr.sbin/bsdinstall/scripts/services (revision 2507698b630db3d88b0aab12c348873f827255a2)
12118f387SNathan Whitehorn#!/bin/sh
22118f387SNathan Whitehorn#-
32118f387SNathan Whitehorn# Copyright (c) 2011 Nathan Whitehorn
42118f387SNathan Whitehorn# All rights reserved.
52118f387SNathan Whitehorn#
62118f387SNathan Whitehorn# Redistribution and use in source and binary forms, with or without
72118f387SNathan Whitehorn# modification, are permitted provided that the following conditions
82118f387SNathan Whitehorn# are met:
92118f387SNathan Whitehorn# 1. Redistributions of source code must retain the above copyright
102118f387SNathan Whitehorn#    notice, this list of conditions and the following disclaimer.
112118f387SNathan Whitehorn# 2. Redistributions in binary form must reproduce the above copyright
122118f387SNathan Whitehorn#    notice, this list of conditions and the following disclaimer in the
132118f387SNathan Whitehorn#    documentation and/or other materials provided with the distribution.
142118f387SNathan Whitehorn#
152118f387SNathan Whitehorn# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
162118f387SNathan Whitehorn# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
172118f387SNathan Whitehorn# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
182118f387SNathan Whitehorn# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
192118f387SNathan Whitehorn# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
202118f387SNathan Whitehorn# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
212118f387SNathan Whitehorn# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
222118f387SNathan Whitehorn# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
232118f387SNathan Whitehorn# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
242118f387SNathan Whitehorn# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
252118f387SNathan Whitehorn# SUCH DAMAGE.
262118f387SNathan Whitehorn#
272118f387SNathan Whitehorn
28cc42ef53SBrad DavisBSDCFG_SHARE="/usr/share/bsdconfig"
29cc42ef53SBrad Davis. $BSDCFG_SHARE/common.subr || exit 1
30cc42ef53SBrad Davis
31852d975cSAlfonso S. Siciliano: ${BSDDIALOG_OK=0}
329cd86fa6SKen Smith
332118f387SNathan Whitehornif [ -f $BSDINSTALL_TMPETC/rc.conf.services ]; then
3491985bc5SJessica Clarke	eval "$( sed -E -e 's/\<(YES|AUTO)\>/on/i' -e 's/\<NO\>/off/i' \
3591985bc5SJessica Clarke		$BSDINSTALL_TMPETC/rc.conf.services )"
362118f387SNathan Whitehornelse
372118f387SNathan Whitehorn	# Default service states. Everything is off if not enabled.
382118f387SNathan Whitehorn	sshd_enable="on"
392118f387SNathan Whitehornfi
402118f387SNathan Whitehorn
412118f387SNathan Whitehornecho -n > $BSDINSTALL_TMPETC/rc.conf.services
422118f387SNathan Whitehorn
43*2507698bSLexi WinterDAEMON_OPTIONS=""
44*2507698bSLexi Winter
45*2507698bSLexi Winterif [ -x "${BSDINSTALL_CHROOT}/etc/rc.d/sshd" ]; then
46*2507698bSLexi Winter	DAEMON_OPTIONS="$DAEMON_OPTIONS \
47*2507698bSLexi Winter	    sshd \"Secure shell daemon\" ${sshd_enable:-off}"
48*2507698bSLexi Winterfi
49*2507698bSLexi Winter
50*2507698bSLexi Winterif [ -x "${BSDINSTALL_CHROOT}/etc/rc.d/ntpd" ]; then
51*2507698bSLexi Winter	DAEMON_OPTIONS="$DAEMON_OPTIONS \
52*2507698bSLexi Winter	    ntpd \"Synchronize system and network time\" ${ntpd_enable:-off} \
53*2507698bSLexi Winter	    ntpd_sync_on_start \"Sync time on ntpd startup, even if offset is high\" \
54*2507698bSLexi Winter		${ntpd_sync_on_start:-off}"
55*2507698bSLexi Winterfi
56*2507698bSLexi Winter
57*2507698bSLexi Winterif [ -x "${BSDINSTALL_CHROOT}/etc/rc.d/local_unbound" ]; then
58*2507698bSLexi Winter	DAEMON_OPTIONS="$DAEMON_OPTIONS \
59*2507698bSLexi Winter	    local_unbound \"Local caching validating resolver\" \
60*2507698bSLexi Winter		${local_unbound_enable:-off}"
61*2507698bSLexi Winterfi
62*2507698bSLexi Winter
63*2507698bSLexi Winterif [ -x "${BSDINSTALL_CHROOT}/etc/rc.d/powerd" ]; then
64*2507698bSLexi Winter	DAEMON_OPTIONS="$DAEMON_OPTIONS \
65*2507698bSLexi Winter	    powerd \"Adjust CPU frequency dynamically if supported\" \
66*2507698bSLexi Winter		${powerd_enable:-off}"
67*2507698bSLexi Winterfi
68*2507698bSLexi Winter
69*2507698bSLexi Winterif [ -x "${BSDINSTALL_CHROOT}/etc/rc.d/moused" ]; then
70*2507698bSLexi Winter	DAEMON_OPTIONS="$DAEMON_OPTIONS \
71*2507698bSLexi Winter	    moused \"PS/2 mouse pointer on console\" ${moused_enable:-off}"
72*2507698bSLexi Winterfi
73*2507698bSLexi Winter
74c0e249d3SLars Kellogg-Stedmanexec 5>&1
75*2507698bSLexi WinterDAEMONS=$(eval bsddialog --backtitle \"$OSNAME Installer\" \
76*2507698bSLexi Winter    --title \"System Configuration\" --no-cancel --separate-output \
77*2507698bSLexi Winter    --checklist \"Choose the services you would like to be started at boot:\" \
782118f387SNathan Whitehorn    0 0 0 \
79*2507698bSLexi Winter	$DAEMON_OPTIONS \
80*2507698bSLexi Winter	dumpdev \"Enable kernel crash dumps to /var/crash\" ${dumpdev:-on} \
81c0e249d3SLars Kellogg-Stedman2>&1 1>&5 )
82852d975cSAlfonso S. Sicilianoretval=$?
83c0e249d3SLars Kellogg-Stedmanexec 5>&-
842118f387SNathan Whitehorn
85852d975cSAlfonso S. Sicilianoif [ $retval -ne $BSDDIALOG_OK ]; then
86852d975cSAlfonso S. Siciliano	exit 1
87852d975cSAlfonso S. Sicilianofi
88852d975cSAlfonso S. Siciliano
899ea4ca85SDevin Teskehavedump=
908cfbeb56SAlfonso S. Sicilianohavemouse=
912118f387SNathan Whitehornfor daemon in $DAEMONS; do
92e06674ffSDevin Teske	[ "$daemon" = "dumpdev" ] && havedump=1 continue
938cfbeb56SAlfonso S. Siciliano	[ "$daemon" = "moused" ] && havemouse=1
941843da3eSJessica Clarke	if [ "$daemon" = "ntpd_sync_on_start" ]; then
951843da3eSJessica Clarke		rcvar=${daemon}
961843da3eSJessica Clarke	else
971843da3eSJessica Clarke		rcvar=${daemon}_enable
981843da3eSJessica Clarke	fi
991843da3eSJessica Clarke	echo ${rcvar}=\"YES\" >> $BSDINSTALL_TMPETC/rc.conf.services
1002118f387SNathan Whitehorndone
1012118f387SNathan Whitehorn
1028cfbeb56SAlfonso S. Sicilianoif [ ! "$havemouse" ]; then
1038cfbeb56SAlfonso S. Siciliano	echo moused_nondefault_enable=\"NO\" >> $BSDINSTALL_TMPETC/rc.conf.services
1048cfbeb56SAlfonso S. Sicilianofi
1058cfbeb56SAlfonso S. Siciliano
106e06674ffSDevin Teskeecho '# Set dumpdev to "AUTO" to enable crash dumps, "NO"' \
107e06674ffSDevin Teske     'to disable' >> $BSDINSTALL_TMPETC/rc.conf.services
108e06674ffSDevin Teskeif [ "$havedump" ]; then
109e06674ffSDevin Teske	echo dumpdev=\"AUTO\" >> $BSDINSTALL_TMPETC/rc.conf.services
110e06674ffSDevin Teskeelse
1119cd86fa6SKen Smith	echo dumpdev=\"NO\" >> $BSDINSTALL_TMPETC/rc.conf.services
1129cd86fa6SKen Smithfi
113