xref: /freebsd/usr.sbin/bsdinstall/scripts/services (revision c0e249d32c780ee8240fe8b3b8144078a8eec41f)
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*c0e249d3SLars Kellogg-Stedmanexec 5>&1
44cc42ef53SBrad DavisDAEMONS=$( bsddialog --backtitle "$OSNAME Installer" \
45852d975cSAlfonso S. Siciliano    --title "System Configuration" --no-cancel --separate-output \
462118f387SNathan Whitehorn    --checklist "Choose the services you would like to be started at boot:" \
472118f387SNathan Whitehorn    0 0 0 \
48bad60285SJessica Clarke	local_unbound "Local caching validating resolver" \
49bad60285SJessica Clarke		${local_unbound_enable:-off} \
502118f387SNathan Whitehorn	sshd	"Secure shell daemon" ${sshd_enable:-off} \
512118f387SNathan Whitehorn	moused	"PS/2 mouse pointer on console" ${moused_enable:-off} \
522118f387SNathan Whitehorn	ntpd	"Synchronize system and network time" ${ntpd_enable:-off} \
53c153a35bSVinícius Zavam	ntpd_sync_on_start	"Sync time on ntpd startup, even if offset is high" \
54c153a35bSVinícius Zavam		${ntpd_sync_on_start:-off} \
5513fba447SDevin Teske	powerd	"Adjust CPU frequency dynamically if supported" \
5613fba447SDevin Teske		${powerd_enable:-off} \
574da57f63SDevin Teske	dumpdev "Enable kernel crash dumps to /var/crash" ${dumpdev:-on} \
58*c0e249d3SLars Kellogg-Stedman2>&1 1>&5 )
59852d975cSAlfonso S. Sicilianoretval=$?
60*c0e249d3SLars Kellogg-Stedmanexec 5>&-
612118f387SNathan Whitehorn
62852d975cSAlfonso S. Sicilianoif [ $retval -ne $BSDDIALOG_OK ]; then
63852d975cSAlfonso S. Siciliano	exit 1
64852d975cSAlfonso S. Sicilianofi
65852d975cSAlfonso S. Siciliano
669ea4ca85SDevin Teskehavedump=
678cfbeb56SAlfonso S. Sicilianohavemouse=
682118f387SNathan Whitehornfor daemon in $DAEMONS; do
69e06674ffSDevin Teske	[ "$daemon" = "dumpdev" ] && havedump=1 continue
708cfbeb56SAlfonso S. Siciliano	[ "$daemon" = "moused" ] && havemouse=1
711843da3eSJessica Clarke	if [ "$daemon" = "ntpd_sync_on_start" ]; then
721843da3eSJessica Clarke		rcvar=${daemon}
731843da3eSJessica Clarke	else
741843da3eSJessica Clarke		rcvar=${daemon}_enable
751843da3eSJessica Clarke	fi
761843da3eSJessica Clarke	echo ${rcvar}=\"YES\" >> $BSDINSTALL_TMPETC/rc.conf.services
772118f387SNathan Whitehorndone
782118f387SNathan Whitehorn
798cfbeb56SAlfonso S. Sicilianoif [ ! "$havemouse" ]; then
808cfbeb56SAlfonso S. Siciliano	echo moused_nondefault_enable=\"NO\" >> $BSDINSTALL_TMPETC/rc.conf.services
818cfbeb56SAlfonso S. Sicilianofi
828cfbeb56SAlfonso S. Siciliano
83e06674ffSDevin Teskeecho '# Set dumpdev to "AUTO" to enable crash dumps, "NO"' \
84e06674ffSDevin Teske     'to disable' >> $BSDINSTALL_TMPETC/rc.conf.services
85e06674ffSDevin Teskeif [ "$havedump" ]; then
86e06674ffSDevin Teske	echo dumpdev=\"AUTO\" >> $BSDINSTALL_TMPETC/rc.conf.services
87e06674ffSDevin Teskeelse
889cd86fa6SKen Smith	echo dumpdev=\"NO\" >> $BSDINSTALL_TMPETC/rc.conf.services
899cd86fa6SKen Smithfi
90