2011-02-18 09:54:34 -05:00
|
|
|
#!/bin/sh
|
|
|
|
|
#-
|
|
|
|
|
# Copyright (c) 2011 Nathan Whitehorn
|
|
|
|
|
# All rights reserved.
|
|
|
|
|
#
|
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
|
# modification, are permitted provided that the following conditions
|
|
|
|
|
# are met:
|
|
|
|
|
# 1. Redistributions of source code must retain the above copyright
|
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
|
|
|
# documentation and/or other materials provided with the distribution.
|
|
|
|
|
#
|
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
|
# SUCH DAMAGE.
|
|
|
|
|
#
|
|
|
|
|
# $FreeBSD$
|
|
|
|
|
|
2022-05-24 11:49:06 -04:00
|
|
|
BSDCFG_SHARE="/usr/share/bsdconfig"
|
|
|
|
|
. $BSDCFG_SHARE/common.subr || exit 1
|
|
|
|
|
|
2022-03-25 19:19:36 -04:00
|
|
|
: ${BSDDIALOG_OK=0}
|
2011-12-01 19:38:47 -05:00
|
|
|
|
2011-02-18 09:54:34 -05:00
|
|
|
if [ -f $BSDINSTALL_TMPETC/rc.conf.services ]; then
|
bsdinstall: Fix issues parsing rc.conf.services on revisit
There are a few issues here, some of which are hiding others. The first
is that we don't use double quotes around the command substitution so
every word in the conf file is treated as a separate argument to eval,
resulting in spaces being used in place of newlines and thus comments in
the file commenting out the rest of the file, not just to the end of
their line. In particular, we insert one comment just before the dumpdev
entry (the final one in the file) and so we never see dumpdev as set,
and thus set a default value of on for the menu.
The second issue is that, for dumpdev, it takes a value of AUTO not YES
when set, but we don't replace this with on when eval'ing, so then end
up giving AUTO to bsddialog which is interpreted the same as off (which
seems to match GPL dialog). Thus handle AUTO like YES otherwise it will
always appear as unchecked on revisit.
The final issue is that our case-insensitive YES/NO (and now AUTO)
replacements have no word boundaries around them so match the middle of
words too. As it happens this doesn't matter in practice at the moment,
but it could in future; currently the only effect is that it rewrites
moused_nondefault_enable to moused_offndefault_enable, but since this
variable is never read, only written based on moused(_enable) this is
harmless, but we should fix it in case a service comes along in future
that does get affected by it.
2022-11-28 21:56:25 -05:00
|
|
|
eval "$( sed -E -e 's/\<(YES|AUTO)\>/on/i' -e 's/\<NO\>/off/i' \
|
|
|
|
|
$BSDINSTALL_TMPETC/rc.conf.services )"
|
2011-02-18 09:54:34 -05:00
|
|
|
else
|
|
|
|
|
# Default service states. Everything is off if not enabled.
|
|
|
|
|
sshd_enable="on"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo -n > $BSDINSTALL_TMPETC/rc.conf.services
|
|
|
|
|
|
|
|
|
|
exec 3>&1
|
2022-05-24 11:49:06 -04:00
|
|
|
DAEMONS=$( bsddialog --backtitle "$OSNAME Installer" \
|
2022-03-25 19:19:36 -04:00
|
|
|
--title "System Configuration" --no-cancel --separate-output \
|
2011-02-18 09:54:34 -05:00
|
|
|
--checklist "Choose the services you would like to be started at boot:" \
|
|
|
|
|
0 0 0 \
|
2022-11-28 22:09:51 -05:00
|
|
|
local_unbound "Local caching validating resolver" \
|
|
|
|
|
${local_unbound_enable:-off} \
|
2011-02-18 09:54:34 -05:00
|
|
|
sshd "Secure shell daemon" ${sshd_enable:-off} \
|
|
|
|
|
moused "PS/2 mouse pointer on console" ${moused_enable:-off} \
|
|
|
|
|
ntpd "Synchronize system and network time" ${ntpd_enable:-off} \
|
2022-09-27 05:04:20 -04:00
|
|
|
ntpd_sync_on_start "Sync time on ntpd startup, even if offset is high" \
|
|
|
|
|
${ntpd_sync_on_start:-off} \
|
2014-01-19 22:39:08 -05:00
|
|
|
powerd "Adjust CPU frequency dynamically if supported" \
|
|
|
|
|
${powerd_enable:-off} \
|
2013-10-11 17:23:44 -04:00
|
|
|
dumpdev "Enable kernel crash dumps to /var/crash" ${dumpdev:-on} \
|
2014-01-19 22:39:08 -05:00
|
|
|
2>&1 1>&3 )
|
2022-03-25 19:19:36 -04:00
|
|
|
retval=$?
|
2011-02-18 09:54:34 -05:00
|
|
|
exec 3>&-
|
|
|
|
|
|
2022-03-25 19:19:36 -04:00
|
|
|
if [ $retval -ne $BSDDIALOG_OK ]; then
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2013-12-12 15:47:18 -05:00
|
|
|
havedump=
|
2022-05-21 10:37:53 -04:00
|
|
|
havemouse=
|
2011-02-18 09:54:34 -05:00
|
|
|
for daemon in $DAEMONS; do
|
2014-01-18 17:33:49 -05:00
|
|
|
[ "$daemon" = "dumpdev" ] && havedump=1 continue
|
2022-05-21 10:37:53 -04:00
|
|
|
[ "$daemon" = "moused" ] && havemouse=1
|
bsdinstall: Fix ntpd_sync_on_start service option
This installer option is currently totally useless, as it ends up
creating an ntpd_sync_on_start_enable="YES" entry in rc.conf, not an
ntpd_sync_on_start="YES" entry, as is the correct name. This can also be
noticed by revisiting the services menu, which parses the previously
written rc.conf.services file to set variables governing the default
menu entry values so that selecting OK regenerates the same file, as the
menu entry will use the correct variable name and thus think the entry
was not selected last time, defaulting back to off and losing the
setting.
Thus, add a special case in the loop for this option. The only other
entry that doesn't follow the *_enable pattern is dumpdev (even moused
does, it just also sets a second variable), but that also deviates in
terms of being explicitly set either way and using AUTO rather than YES,
hence why ntpd_sync_on_start follows a different pattern here and is
special-cased rather than introducing a whole new variable that governs
behaviour outside the loop.
Fixes: c153a35bfd71 ("bsdinstall: replace ntpdate by ntpd_sync_on_start")
2022-11-28 19:57:38 -05:00
|
|
|
if [ "$daemon" = "ntpd_sync_on_start" ]; then
|
|
|
|
|
rcvar=${daemon}
|
|
|
|
|
else
|
|
|
|
|
rcvar=${daemon}_enable
|
|
|
|
|
fi
|
|
|
|
|
echo ${rcvar}=\"YES\" >> $BSDINSTALL_TMPETC/rc.conf.services
|
2011-02-18 09:54:34 -05:00
|
|
|
done
|
|
|
|
|
|
2022-05-21 10:37:53 -04:00
|
|
|
if [ ! "$havemouse" ]; then
|
|
|
|
|
echo moused_nondefault_enable=\"NO\" >> $BSDINSTALL_TMPETC/rc.conf.services
|
|
|
|
|
fi
|
|
|
|
|
|
2014-01-18 17:33:49 -05:00
|
|
|
echo '# Set dumpdev to "AUTO" to enable crash dumps, "NO"' \
|
|
|
|
|
'to disable' >> $BSDINSTALL_TMPETC/rc.conf.services
|
|
|
|
|
if [ "$havedump" ]; then
|
|
|
|
|
echo dumpdev=\"AUTO\" >> $BSDINSTALL_TMPETC/rc.conf.services
|
|
|
|
|
else
|
2011-12-01 19:38:47 -05:00
|
|
|
echo dumpdev=\"NO\" >> $BSDINSTALL_TMPETC/rc.conf.services
|
|
|
|
|
fi
|