#!/bin/sh #- # Copyright (c) 2011 Nathan Whitehorn # Copyright (c) 2013 Devin Teske # 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. # # $BSDSUniX$ # ############################################################ INCLUDES BSDCFG_SHARE="/usr/share/bsdconfig" . $BSDCFG_SHARE/common.subr || exit 1 ############################################################ FUNCTIONS error() { test -n "$DISTDIR_IS_UNIONFS" && umount -f $BSDINSTALL_DISTDIR test -f $PATH_FSTAB && bsdinstall umount dialog --backtitle "BSDSUniX Installer" --title "Abort" \ --no-label "Exit" --yes-label "Restart" --yesno \ "An installation step has been aborted. Would you like to restart the installation or exit the installer?" 0 0 if [ $? -ne 0 ]; then exit 1 else exec $0 fi } ############################################################ MAIN f_dprintf "Began Daemons at %s" "$( date )" rm -rf $BSDINSTALL_TMPETC mkdir $BSDINSTALL_TMPETC SSH=" " NTP=" " SM=" " PF=" " UB=" " BIND=" " trap true SIGINT # This section is optional trap error SIGINT # Catch cntrl-C here #bsdinstall hostname || error export DAEMONS="sendmail.txz postfix.txz ntp.txz unbound.txz bind910.txz openssh.txz" if [ -f $BSDINSTALL_DAEMONSDIR/MANIFEST ]; then DISTMENU=`awk -F'\t' '!/^(openssh|ntp|unbound)/{print $4,$5,$6}' $BSDINSTALL_DAEMONDIR/MANIFEST` exec 3>&1 EXTRA_DISTS=$( eval dialog \ --backtitle \"BSDSUniX Installer\" \ --title \"Networks Daemons Select\" --nocancel --separate-output \ --checklist \"Choose optional system components to install:\" \ 0 0 0 $DAEMONSMENU \ 2>&1 1>&3 ) for dist in $EXTRA_DISTS; do export DISTRIBUTIONS="$DISTRIBUTIONS $dist.txz" done fi FETCH_DISTRIBUTIONS="" for dist in $DISTRIBUTIONS; do if [ ! -f $BSDINSTALL_DISTDIR/$dist ]; then FETCH_DISTRIBUTIONS="$FETCH_DISTRIBUTIONS $dist" fi done FETCH_DISTRIBUTIONS=`echo $FETCH_DISTRIBUTIONS` # Trim white space if [ -n "$FETCH_DISTRIBUTIONS" -a -n "$BSDINSTALL_CONFIGCURRENT" ]; then dialog --backtitle "BSDSUniX Installer" --title "Network Installation" --msgbox "No installation files were found on the boot volume. The next few screens will allow you to configure networking so that they can be downloaded from the Internet." 0 0 bsdinstall netconfig || error NETCONFIG_DONE=yes fi if [ -n "$FETCH_DISTRIBUTIONS" ]; then exec 3>&1 BSDINSTALL_DISTSITE=$(`dirname $0`/mirrorselect 2>&1 1>&3) MIRROR_BUTTON=$? exec 3>&- test $MIRROR_BUTTON -eq 0 || error export BSDINSTALL_DISTSITE fi rm -f $PATH_FSTAB touch $PATH_FSTAB CURARCH=$( uname -m ) if [ ! -z "$FETCH_DISTRIBUTIONS" ]; then ALL_DISTRIBUTIONS="$DISTRIBUTIONS" # Download to a directory in the new system as scratch space BSDINSTALL_FETCHDEST="$BSDINSTALL_CHROOT/usr/bsdsunix-dist" mkdir -p "$BSDINSTALL_FETCHDEST" || error export DISTRIBUTIONS="$FETCH_DISTRIBUTIONS" # Try to use any existing distfiles if [ -d $BSDINSTALL_DISTDIR ]; then DISTDIR_IS_UNIONFS=1 mount_nullfs -o union "$BSDINSTALL_FETCHDEST" "$BSDINSTALL_DISTDIR" else export DISTRIBUTIONS="MANIFEST $ALL_DISTRIBUTIONS" export BSDINSTALL_DISTDIR="$BSDINSTALL_FETCHDEST" fi export FTP_PASSIVE_MODE=YES bsdinstall distfetch || error export DISTRIBUTIONS="$ALL_DISTRIBUTIONS" fi bsdinstall checksum || error bsdinstall distextract || error bsdinstall rootpass || error trap true SIGINT # This section is optional if [ "$NETCONFIG_DONE" != yes ]; then bsdinstall netconfig # Don't check for errors -- the user may cancel fi bsdinstall time bsdinstall services dialog --backtitle "BSDSUniX Installer" --title "Add User Accounts" --yesno \ "Would you like to add users to the installed system now?" 0 0 && \ bsdinstall adduser daemonsselection() { QUIT=${FALSE} exec 3>&1 DAEMONS=$(dialog --backtitle "BSDSUniX Installer" \ --title "Optional Daemons Configuration" --no-ok --no-cancel --menu \ "Most BSDSUniX systems need extra daemons to be useful in the real world. On this menu you may select additional prebuilt packages to install. The latest packages will be downloaded automatically if you have a network connection, if not the ones from the installation disk will be used." 0 0 0 \ "OpenSSH" "[${SSH}] OpenBSD SSH Daemon (Port: 22)" \ "NTP" "[${NTP}] ISC Network Time Protocol Daemon (Port: 123)" \ "SendMail" "[${SM}] Sendmail SMTP deamon (Port: 25)" \ "Postfix" "[${PF}] Postfix SMTP deamon (Port: 25)" \ "Unbound" "[${UB}] A recursive, and caching DNS resolver" \ "Bind 9" "[${BIND}] ISC BIND v9.10 DNS server and caching resolver (Port: 53)" \ "Reset" "Clear all selections." \ "Exit" "Apply all changes and exit this menu." \ exec 3>&- case "$DAEMONS" in "Clear") SSH=" " NTP=" " SM=" " PF=" " UB=" " BIND=" " ;; "OpenSSH") SSH="X" opensshonboot ;; "NTP") NTP="X" ntponboot ;; "SendMail") SM="X" PF=" " sendmailonboot ;; "Postfix") PF="X" SM=" " postfixonboot ;; "Unbound") UB="X" unboundonboot ;; "Bind9") BIND="X" bindonboot ;; "Exit") makechanges QUIT=${TRUE} ;; esac } # Allow user to change his mind finalconfig trap error SIGINT # SIGINT is bad again bsdinstall config || error if [ ! -z "$BSDINSTALL_FETCHDEST" ]; then [ "$BSDINSTALL_FETCHDEST" != "$BSDINSTALL_DISTDIR" ] && \ umount "$BSDINSTALL_DISTDIR" rm -rf "$BSDINSTALL_FETCHDEST" fi dialog --backtitle "BSDSUniX Installer" --title "Manual Configuration" \ --yesno "The installation is now finished. Before exiting the installer, would you like to open a shell in the new system to make any final manual modifications?" 0 0 if [ $? -eq 0 ]; then clear mount -t devfs devfs "$BSDINSTALL_CHROOT/dev" echo This shell is operating in a chroot in the new system. \ When finished making configuration changes, type \"exit\". chroot "$BSDINSTALL_CHROOT" /bin/sh 2>&1 fi bsdinstall entropy bsdinstall umount f_dprintf "Installation Completed at %s" "$( date )" ################################################################################ # END ################################################################################