- #!/bin/sh
- ################################################################################
- # Copyright (c) 2016, Manuel Strauch (manuel.strauch@outlook.com)
- # All rights reserved.
- #
- # Redistribution and use in source and binary forms, with or without
- # modification, are permitted provided that the following conditions are met:
- #
- # -Redistributions of source code must retain the above copyright notice,
- # this list of conditions and the following disclaimer.
- # -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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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.
- ################################################################################
- ### Config
- scriptversion="3.1.0"
- freebsdversion="11.0"
- freebsdtype="RELEASE"
- zfs_needed_mem="4"
- sourcedir="/usb/FreeBSD_install"
- destinationdir="/mnt/install"
- installdir="/mnt"
- prg_gpart="/sbin/gpart"
- prg_zfs="/sbin/zfs"
- prg_zpool="/sbin/zpool"
- freebsdurl="http://ftp2.de.freebsd.org/pub/FreeBSD/releases"
- ### Program (DONT TOUCH)
- DONE="\033[80C\033[11D\033[1;34m -= OK =-\033[m"
- GREEN="\033[1;32m"
- RED="\033[1;31m"
- NORMAL="\033[m"
- DOWNLOADDONE="\033[2A\033[80C\033[11D\033[1;34m -= OK =-\033[1B\033[m"
- amd64pkg="base.txz doc.txz kernel.txz lib32.txz"
- jaili386="base.txz doc.txz"
- jailamd64="base.txz doc.txz lib32.txz"
- mfsportspkg=" ../../ports.txz"
- mfssrcpkg=" ../../src.txz"
- portspkg=" ports.txz"
- srcpkg=" src.txz"
- realmem="`dmesg | grep "real memory" | sed -e 's/[^ ].* = \([0-9].*\) ([^ ].*$/\1/'`"
- realmem_format="`expr ${realmem} / 1024 / 1024 / 1024`"
- installmode="normal"
- masterjail="no"
- arch="`uname -m`"
- mfs="no"
- tmpfs="no"
- zfs="no"
- ports="no"
- src="no"
- ################################################################################
- ################################################################################
- find_options() {
- shift
- for i in ${@}; do
- option="`echo "${i}" | cut -f1 -d':'`"
- case "${option}" in
- --installmode | -i)
- t="`echo "${i}" | cut -f2 -d':'`"
- if [ "${t}" = "db-or-mail" ] || [ "${t}" = "alix" ]; then
- installmode="${t}"
- fi
- ;;
- --masterjail | -mj)
- t="`echo "${i}" | cut -f2 -d':'`"
- if [ "${t}" = "jroot" ]; then
- masterjail="jroot"
- fi
- if [ "${t}" = "normal" ]; then
- masterjail="normal"
- fi
- ;;
- --tmpfs | -t)
- t="`echo "${i}" | cut -f2 -d':'`"
- if [ "${t}" = "yes" ] || [ "${t}" = "-t" ]; then
- tmpfs="yes"
- fi
- ;;
- --zfs | -z)
- t="`echo "${i}" | cut -f2 -d':'`"
- if [ "${t}" = "yes" ] || [ "${t}" = "-z" ]; then
- if [ ${realmem_format} -lt ${zfs_needed_mem} ]; then
- zfs_info="zfs use min. ${zfs_needed_mem}GB RAM, i will use ufs2!"
- zfs="no"
- else
- zfs="yes"
- kldload opensolaris
- kldload zfs
- fi
- fi
- ;;
- --ports | -p)
- t="`echo "${i}" | cut -f2 -d':'`"
- if [ "${t}" = "yes" ] || [ "${t}" = "-p" ]; then
- ports="yes"
- if [ -e /etc/hsi-version ]; then
- amd64pkg="${amd64pkg} ${mfsportspkg}"
- else
- amd64pkg="${amd64pkg} ${portspkg}"
- fi
- fi
- ;;
- --source | -s)
- t="`echo "${i}" | cut -f2 -d':'`"
- if [ "${t}" = "yes" ] || [ "${t}" = "-s" ]; then
- src="yes"
- if [ -e /etc/hsi-version ]; then
- amd64pkg="${amd64pkg} ${mfssrcpkg}"
- else
- amd64pkg="${amd64pkg} ${srcpkg}"
- fi
- fi
- ;;
- *)
- echo "syntax error!!"
- echo "option { "${i}" } was not supported!"
- exit 1
- ;;
- esac
- done
- }
- ################################################################################
- ################################################################################
- find_mfsbsd() {
- ### only when special mfsbsd was booted
- if [ -e /etc/hsi-version ]; then
- mfs="yes"
- mount -t cd9660 /dev/cd0 /cdrom
- sourcedir="/cdrom"
- fi
- }
- ################################################################################
- ################################################################################
- check_options() {
- if [ "${zfs}" = "yes" ]; then
- arch="amd64"
- fi
- clear
- echo "starting installer version ${scriptversion} for FreeBSD ${freebsdversion}-${freebsdtype}"
- echo " --> installing FreeBSD on ${1} with the following options:"
- echo -e "\033[6C\033[m installmode = ${GREEN}${installmode}${NORMAL}"
- echo -e "\033[6C\033[m masterjail\033[1C = ${GREEN}${masterjail}${NORMAL}"
- echo -e "\033[6C\033[m arch\033[7C = ${GREEN}${arch}${NORMAL}"
- echo -e "\033[6C\033[m tmpfs\033[6C = ${GREEN}${tmpfs}${NORMAL}"
- echo -e "\033[6C\033[m MFS\033[8C = ${GREEN}${mfs}${NORMAL}"
- echo -e "\033[6C\033[m Source\033[5C = ${GREEN}${src}${NORMAL}"
- echo -e "\033[6C\033[m Ports\033[6C = ${GREEN}${ports}${NORMAL}"
- echo -e "\033[6C\033[m ZFS\033[8C = ${GREEN}${zfs}${NORMAL}"
- echo -e "\033[20C\033[m ${RED}${zfs_info}${NORMAL}"
- echo
- echo -n "Press (y) to start the installation: "
- read startinstall
- if [ "${startinstall}" != "y" ]; then
- exit 0
- fi
- }
- ################################################################################
- ################################################################################
- create_ufs_partitions() {
- echo -n " --> destroy all partitions on ${1}"
- ${prg_gpart} destroy -F ${1} >/dev/null 2>&1
- echo -e "${DONE}"
- echo -n " --> create GPT on ${1}"
- ${prg_gpart} create -s gpt ${1} >/dev/null 2>&1
- echo -e "${DONE}"
- echo -n " --> create boot partition on ${1}"
- ${prg_gpart} add -s 128k -t freebsd-boot -l boot -i 1 ${1} >/dev/null 2>&1
- echo -e "${DONE}"
- echo -n " --> insert bootcode on ${1}"
- ${prg_gpart} bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ${1} >/dev/null 2>&1
- echo -e "${DONE}"
- if [ "${installmode}" = "alix" ]; then
- echo -n " --> create root partition on ${1}"
- ${prg_gpart} add -t freebsd-ufs -l root -i 2 ${1} >/dev/null 2>&1
- echo -e "${DONE}"
- echo -n " --> UFS format all partitions "
- newfs -O2 "/dev/${1}p2" >/dev/null 2>&1
- echo -e "${DONE}"
- echo -n " --> mount all partitions "
- if [ ! -d "${installdir}" ]; then
- mkdir "${installdir}"
- fi
- mount "/dev/${1}p2" "${installdir}"
- mkdir "${destinationdir}"
- echo -e "${DONE}"
- else
- z=2
- echo -n " --> create 2GB swap partition on ${1}"
- ${prg_gpart} add -s 2G -t freebsd-swap -i ${z} ${1} >/dev/null 2>&1
- echo -e "${DONE}"
- z=`expr ${z} + 1`
- echo -n " --> create 1GB root partition on ${1}"
- ${prg_gpart} add -s 1G -t freebsd-ufs -l root -i ${z} ${1} >/dev/null 2>&1
- echo -e "${DONE}"
- if [ "${tmpfs}" = "no" ]; then
- z=`expr ${z} + 1`
- echo -n " --> create 1GB tmp partition on ${1}"
- ${prg_gpart} add -s 1G -t freebsd-ufs -l tmp -i ${z} ${1} >/dev/null 2>&1
- echo -e "${DONE}"
- fi
- z=`expr ${z} + 1`
- if [ ${installmode} = "db-or-mail" ]; then
- echo -n " --> create 15GB var partition on ${1}"
- ${prg_gpart} add -s 15G -t freebsd-ufs -l var -i ${z} ${1} >/dev/null 2>&1
- echo -e "${DONE}"
- else
- echo -n " --> create 2GB var partition on ${1}"
- ${prg_gpart} add -s 2G -t freebsd-ufs -l var -i ${z} ${1} >/dev/null 2>&1
- echo -e "${DONE}"
- fi
- z=`expr ${z} + 1`
- echo -n " --> create usr partition on ${1}"
- ${prg_gpart} add -t freebsd-ufs -l usr -i ${z} ${1} >/dev/null 2>&1
- echo -e "${DONE}"
- echo -n " --> UFS format all partitions "
- if [ ${tmpfs} = "yes" ]; then
- partitions="${1}p3 ${1}p4 ${1}p5"
- else
- partitions="${1}p3 ${1}p4 ${1}p5 ${1}p6"
- fi
- for i in ${partitions}; do
- if [ "${i}" = "${1}p3" ]; then
- newfs -O2 "/dev/${1}p3" >/dev/null 2>&1
- else
- newfs -O2 -U "/dev/${i}" >/dev/null 2>&1
- fi
- done
- echo -e "${DONE}"
- echo -n " --> mount all partitions "
- if [ ! -d "${installdir}" ]; then
- mkdir "${installdir}"
- fi
- mount "/dev/${1}p3" "${installdir}"
- mkdir "${destinationdir}"
- mkdir "${installdir}/tmp" "${installdir}/var" "${installdir}/usr"
- if [ ${tmpfs} = "no" ]; then
- mount "/dev/${1}p4" "${installdir}/tmp"
- mount "/dev/${1}p5" "${installdir}/var"
- mount "/dev/${1}p6" "${installdir}/usr"
- else
- mount "/dev/${1}p4" "${installdir}/var"
- mount "/dev/${1}p5" "${installdir}/usr"
- fi
- echo -e "${DONE}"
- fi
- }
- ################################################################################
- ################################################################################
- create_zfs_partitions() {
- echo -n " --> destroy all partitions on ${1}"
- ${prg_gpart} destroy -F ${1} >/dev/null 2>&1
- echo -e "${DONE}"
- echo -n " --> create GPT on ${1}"
- ${prg_gpart} create -s gpt ${1} >/dev/null 2>&1
- echo -e "${DONE}"
- echo -n " --> create boot partition on ${1}"
- ${prg_gpart} add -s 128k -t freebsd-boot -l boot -i 1 ${1} >/dev/null 2>&1
- echo -e "${DONE}"
- echo -n " --> insert bootcode on ${1}"
- ${prg_gpart} bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ${1} >/dev/null 2>&1
- echo -e "${DONE}"
- echo -n " --> create 2GB swap partition on ${1}"
- ${prg_gpart} add -s 2G -t freebsd-swap -i 2 ${1} >/dev/null 2>&1
- echo -e "${DONE}"
- echo -n " --> create tank partition on ${1}"
- ${prg_gpart} add -t freebsd-zfs -l root -i 3 ${1} >/dev/null 2>&1
- echo -e "${DONE}"
- echo -n " --> create tank on ${1}p3"
- ${prg_zpool} create -f -O checksum=fletcher4 -O atime=off -O canmount=off -O mountpoint=${installdir} tank ${1}p3
- ${prg_zfs} create -o mountpoint=legacy -o setuid=on tank/root
- if [ ! -d "${installdir}" ]; then
- mkdir "${installdir}"
- fi
- mount -t zfs tank/root "${installdir}"
- ${prg_zfs} create -o canmount=off tank/usr
- ${prg_zfs} create tank/usr/home
- ${prg_zfs} create -o compress=lzjb -o exec=off tank/usr/obj
- ${prg_zfs} create -o compress=gzip tank/usr/ports
- ${prg_zfs} create -o compress=off -o exec=off tank/usr/ports/distfiles
- ${prg_zfs} create -o compress=off -o exec=off tank/usr/ports/packages
- ${prg_zfs} create -o compress=gzip -o exec=off tank/usr/src
- ${prg_zfs} create -o exec=off -o canmount=off tank/var
- ${prg_zfs} create -o compress=lzjb tank/var/audit
- ${prg_zfs} create -o compress=lzjb tank/var/crash
- ${prg_zfs} create tank/var/db
- ${prg_zfs} create -o compress=lzjb -o exec=on tank/var/db/pkg
- ${prg_zfs} create tank/var/empty
- ${prg_zfs} create -o compress=gzip tank/var/log
- ${prg_zfs} create -o compress=gzip tank/var/mail
- ${prg_zfs} create tank/var/run
- mkdir "${destinationdir}"
- mkdir "${installdir}/tmp"
- echo -e "${DONE}"
- }
- ################################################################################
- ################################################################################
- download_needed_files() {
- echo " --> install FreeBSD ${freebsdversion}-${freebsdtype} ${arch}"
- pkg="${amd64pkg}"
- if [ -d "${sourcedir}/${freebsdversion}/${arch}" ]; then
- echo " --> found local install files"
- for i in ${pkg}; do
- echo -n " --> copy file ${i} to ${destinationdir}"
- cp "${sourcedir}/${freebsdversion}/${arch}/${i}" "${destinationdir}"
- echo -e "${DONE}"
- done
- else
- echo " --> download install files"
- for i in ${pkg}; do
- echo -n " --> download file ${i} to ${destinationdir}"
- cd "${destinationdir}"
- fetch "${freebsdurl}/${arch}/${freebsdversion}-${freebsdtype}/${i}"
- echo -e "${DOWNLOADDONE}"
- done
- fi
- }
- ################################################################################
- ################################################################################
- install_freebsd() {
- cd "${installdir}"
- for i in `ls -1 ${destinationdir}/*.txz`; do
- echo -n " --> install file ${i} to ${installdir}"
- tar -xzpf "${i}"
- echo -e "${DONE}"
- done
- if [ ! -d usr/ports ]; then
- mkdir usr/ports
- fi
- if [ ! -d usr/src ]; then
- mkdir usr/src
- fi
- }
- ################################################################################
- ################################################################################
- configure_ufs_freebsd() {
- echo -n " --> create ${installdir}/etc/fstab"
- if [ ${installmode} = "alix" ]; then
- if [ ${tmpfs} = "yes" ]; then
- echo "/dev/${1}p2 / ufs rw 1 1
- tmpfs /tmp tmpfs rw,mode=777 0 0
- " > "${installdir}/etc/fstab"
- else
- echo "/dev/${1}p2 / ufs rw 1 1 " > "${installdir}/etc/fstab"
- fi
- else
- if [ ${tmpfs} = "yes" ]; then
- echo "/dev/${1}p2 none swap sw 0 0
- /dev/${1}p3 / ufs rw 1 1
- tmpfs /tmp tmpfs rw,mode=777 0 0
- /dev/${1}p4 /var ufs rw 2 2
- /dev/${1}p5 /usr ufs rw 2 2
- " > "${installdir}/etc/fstab"
- else
- echo "/dev/${1}p2 none swap sw 0 0
- /dev/${1}p3 / ufs rw 1 1
- /dev/${1}p4 /tmp ufs rw 2 2
- /dev/${1}p5 /var ufs rw 2 2
- /dev/${1}p6 /usr ufs rw 2 2
- " > "${installdir}/etc/fstab"
- fi
- fi
- echo "fdesc /dev/fd fdescfs rw 0 0" >> "${installdir}/etc/fstab"
- echo -e "${DONE}"
- echo -n " --> create ${installdir}/etc/rc.conf"
- all_interfaces="`ifconfig | egrep "^[a-z][a-z]?[a-z]?[a-z][0-9]" | cut -f1 -d':'`"
- echo 'hostname="beastie.freebsd.local"' > "${installdir}/etc/rc.conf"
- for i in ${all_interfaces}; do
- if [ "${i}" != "lo0" ] ; then
- echo "ifconfig_${i}=\"DHCP\"" >> "${installdir}/etc/rc.conf"
- fi
- done
- echo '
- keymap="de"
- keyrate="fast"
- scrnmap="NO"
- #### Services
- sshd_enable="YES"
- sendmail_enable="NONE"
- sendmail_outbound_enable="NO"
- sendmail_submit_enable="NO"
- sendmail_msp_queue_enable="NO"
- vm_enable="YES"
- vm_dir="/home/bhyve"
- ' >> "${installdir}/etc/rc.conf"
- echo -e "${DONE}"
- echo -n " --> create ${installdir}/etc/sysctl.conf"
- echo 'kern.coredump=0
- ### Hyper-V WLAN
- net.link.ether.inet.max_age=60
- ### bhyve
- net.link.tap.up_on_open=1
- ' >> "${installdir}/etc/sysctl.conf"
- echo -e "${DONE}"
- echo -n " --> create ${installdir}/boot/loader.conf"
- echo 'loader_color="YES"
- loader_logo="beastie"
- vmm_load="YES"
- nmdm_load="YES"
- if_bridge_load="YES"
- if_tap_load="YES"
- ' > "${installdir}/boot/loader.conf"
- echo -e "${DONE}"
- }
- configure_zfs_freebsd() {
- echo -n " --> create ${installdir}/etc/fstab"
- if [ ${tmpfs} = "yes" ]; then
- echo "/dev/${1}p2 none swap sw 0 0
- tmpfs /tmp tmpfs rw,mode=777 0 0
- " > "${installdir}/etc/fstab"
- else
- echo "/dev/${1}p2 none swap sw 0 0
- " > "${installdir}/etc/fstab"
- fi
- echo "fdesc /dev/fd fdescfs rw 0 0" >> "${installdir}/etc/fstab"
- echo -e "${DONE}"
- echo -n " --> create ${installdir}/etc/rc.conf"
- all_interfaces="`ifconfig | egrep "^[a-z][a-z]?[a-z]?[a-z][0-9]" | cut -f1 -d':'`"
- echo 'hostname="beastie.freebsd.local"' > "${installdir}/etc/rc.conf"
- for i in ${all_interfaces}; do
- if [ "${i}" != "lo0" ] ; then
- echo "ifconfig_${i}=\"DHCP\"" >> "${installdir}/etc/rc.conf"
- fi
- done
- echo '
- keymap="de"
- keyrate="fast"
- scrnmap="NO"
- #### Services
- zfs_enable="YES"
- sshd_enable="YES"
- sendmail_enable="NONE"
- sendmail_outbound_enable="NO"
- sendmail_submit_enable="NO"
- sendmail_msp_queue_enable="NO"
- vm_enable="YES"
- vm_dir="/home/bhyve"
- ' >> "${installdir}/etc/rc.conf"
- echo -e "${DONE}"
- echo -n " --> create ${installdir}/etc/sysctl.conf"
- echo 'kern.coredump=0
- ### Hyper-V WLAN
- net.link.ether.inet.max_age=60
- ### bhyve
- net.link.tap.up_on_open=1
- ' >> "${installdir}/etc/sysctl.conf"
- echo -e "${DONE}"
- echo -n " --> create ${installdir}/boot/loader.conf"
- echo 'loader_color="YES"
- loader_logo="beastie"
- zfs_load="YES"
- vfs.root.mountfrom="zfs:tank/root"
- vm.kmem_size="512M"
- vm.kmem_size_max="512M"
- vfs.zfs.arc_max="40M"
- vfs.zfs.vdev.cache.size="5M"
- vmm_load="YES"
- nmdm_load="YES"
- if_bridge_load="YES"
- if_tap_load="YES"
- ' > "${installdir}/boot/loader.conf"
- echo -e "${DONE}"
- }
- ################################################################################
- ################################################################################
- configure_freebsd_part2() {
- echo -n " --> create resolv.conf"
- cp /etc/resolv.conf "${installdir}/etc/resolv.conf"
- mkdir "${installdir}/usr/local/etc" >/dev/null 2>&1
- mkdir "${installdir}/usr/local/etc/rc.d" >/dev/null 2>&1
- ln -s /opt/bin/install_default_pkg.sh "${installdir}/usr/local/etc/rc.d/Z99_install_default_pkg.sh"
- echo -e "${DONE}"
- echo -n " --> setting up timezone to Europe/Berlin"
- cp "${installdir}/usr/share/zoneinfo/Europe/Berlin" \
- "${installdir}/etc/localtime"
- echo -e "${DONE}"
- echo -n " --> configure syslog daemon"
- cp ${sourcedir}/syslog.conf "${installdir}/etc/syslog.conf"
- echo -e "${DONE}"
- }
- ################################################################################
- ################################################################################
- install_opt() {
- echo -n " --> install /opt"
- cd ${installdir}
- if [ "${mfs}" = "no" ]; then
- fetch http://www.anukis.de/download/opt.tgz >/dev/null 2>&1
- else
- cp ${sourcedir}/opt.tgz .
- fi
- tar -xzf opt.tgz
- chown -R root:wheel opt/
- rm opt.tgz
- echo -e "${DONE}"
- }
- ################################################################################
- ################################################################################
- install_jail_normal() {
- if [ "${masterjail}" = "normal" ]; then
- echo " --> install masterjail ${installdir}/usr/jails/sample"
- mkdir "${installdir}/usr/jails" "${installdir}/usr/jails/sample"
- pkg="${jailamd64}"
- cd "${installdir}/usr/jails/sample"
- for i in ${pkg}; do
- echo -n " --> install file ${i} to ${installdir}/usr/jails/sample"
- tar -xzpf "${destinationdir}/${i}"
- echo -e "${DONE}"
- done
- echo -n " --> setting up timezone and default configs"
- touch etc/fstab
- cp "${installdir}/usr/share/zoneinfo/Europe/Berlin" \
- "${installdir}/usr/jails/sample/etc/localtime"
- cp "${installdir}/etc/hosts" \
- "${installdir}/usr/jails/sample/etc/hosts"
- cp "${installdir}/etc/resolv.conf" \
- "${installdir}/usr/jails/sample/etc/resolv.conf"
- mkdir usr/home usr/ports usr/src 2>/dev/null
- ln -s usr/home home
- echo "
- ### JAILS
- /usr/ports /usr/jails/sample/usr/ports nullfs ro 0 0
- /usr/src /usr/jails/sample/usr/src nullfs ro 0 0
- " >>"${installdir}/usr/jails/fstab.sample"
- echo -e "${DONE}"
- fi
- }
- ################################################################################
- ################################################################################
- install_jail_jroot() {
- if [ "${masterjail}" = "jroot" ]; then
- echo " --> install masterjail ${installdir}/usr/jails/jroot"
- mkdir "${installdir}/usr/jails" "${installdir}/usr/jails/jroot" "${installdir}/usr/jails/skel"
- pkg="${jailamd64}"
- cd "${installdir}/usr/jails/jroot"
- for i in ${pkg}; do
- echo -n " --> install file ${i} to ${installdir}/usr/jails/jroot"
- tar -xzpf "${destinationdir}/${i}"
- echo -e "${DONE}"
- done
- echo -n " --> create ${installdir}/usr/jails/skel"
- cd "${installdir}/usr/"
- mkdir jails/jroot/usr/ports >/dev/null 2>&1
- mkdir jails/jroot/usr/src >/dev/null 2>&1
- cd jails/skel
- mkdir home usr-X11R6 distfiles portbuild packages
- cd ../jroot
- mkdir s
- mv etc ../skel
- mv usr/local ../skel/usr-local
- mv tmp ../skel
- mv var ../skel
- mv root ../skel
- ln -s s/etc etc
- ln -s s/home home
- ln -s s/root root
- ln -s ../s/usr-local usr/local
- ln -s ../s/usr-X11R6 usr/X11R6
- ln -s ../../s/distfiles usr/ports/distfiles
- ln -s s/tmp tmp
- ln -s s/var var
- cd ../skel
- echo "WRKDIRPREFIX?=/s/portbuild" >>etc/make.conf
- echo "DISTDIR=/s/distfiles" >>etc/make.conf
- echo "PACKAGES=/tmp" >>etc/make.conf
- touch etc/fstab
- cp "${installdir}/usr/share/zoneinfo/Europe/Berlin" \
- "${installdir}/usr/jails/skel/etc/localtime"
- cp "${installdir}/etc/hosts" \
- "${installdir}/usr/jails/skel/etc/hosts"
- cp "${installdir}/etc/resolv.conf" \
- "${installdir}/usr/jails/skel/etc/resolv.conf"
- echo -e "${DONE}"
- echo -n " --> install sample jail"
- cd ..
- mkdir sample
- cp -Rp skel sample_skel
- echo "
- ### JAILS
- /usr/jails/jroot /usr/jails/sample nullfs ro 0 0
- /usr/jails/sample_skel /usr/jails/sample/s nullfs rw 0 0
- /usr/ports /usr/jails/sample/usr/ports nullfs rw 0 0
- /usr/src /usr/jails/sample/usr/src nullfs rw 0 0
- " >"${installdir}/usr/jails/fstab.sample"
- echo -e "${DONE}"
- fi
- }
- ################################################################################
- ################################################################################
- configure_jail() {
- if [ "${masterjail}" != "no" ]; then
- echo " --> configure sample jail"
- if [ "${masterjail}" = "normal" ]; then
- jailpath="${installdir}/usr/jails/sample"
- else
- jailpath="${installdir}/usr/jails/sample_skel"
- fi
- ## create Jail make.conf
- echo -n " --> create ${jailpath}/etc/make.conf"
- (
- cat <<__EOF__
- WRKDIRPREFIX?=/tmp
- DISTDIR=/home/distfiles
- PACKAGES=/tmp
- DOC_LANG=de_DE.ISO8859-1
- # -----------------------------------------------------------------------------
- # Fetching from de sites preferred
- MASTER_SORT_REGEX?=://[^/]*\.de[/.]
- # -----------------------------------------------------------------------------
- KERNCONF=GENERIC
- # wget statt fetch zum downloaden der ports benutzen. falls existiert
- .if exists(/usr/local/bin/wget)
- DISABLE_SIZE= yes
- FETCH_CMD= /usr/local/bin/wget --continue --passive-ftp -t 2 -T 15
- .endif
- # --- common ----------------------------------------------------------------
- # Default build flags.
- #CPUTYPE?= pentium-m
- CFLAGS=-O2 -pipe
- # -----------------------------------------------------------------------------
- # --- common for all ports --------------------------------------------------
- BATCH=YES
- WITHOUT_DEBUG=yes
- # -----------------------------------------------------------------------------
- WITH_PKGNG=yes
- __EOF__
- ) > "${jailpath}/etc/make.conf"
- echo -e "${DONE}"
- ## create Jail rc.conf
- echo -n " --> create ${jailpath}/etc/rc.conf"
- (
- cat <<__EOF__
- syslogd_flags="-s -s"
- newsyslog_enable="NO"
- syslogd_enable="NO"
- sendmail_enable="NONE"
- sendmail_outbound_enable="NO"
- sendmail_submit_enable="NO"
- sendmail_msp_queue_enable="NO"
- __EOF__
- ) > "${jailpath}/etc/rc.conf"
- echo -e "${DONE}"
- ## create Jail hosts
- echo -n " --> create ${jailpath}/etc/hosts"
- (
- cat <<__EOF__
- 192.168.20.1 sample sample.freebsd.local
- __EOF__
- ) > "${jailpath}/etc/hosts"
- echo -e "${DONE}"
- fi
- }
- ################################################################################
- ################################################################################
- dismount_mfsbsd() {
- if [ ${mfs} = "yes" ]; then
- umount /cdrom
- fi
- }
- ################################################################################
- ################################################################################
- finished() {
- if [ ${zfs} = "yes" ]; then
- if [ ! -d ${installdir}/boot/zfs ]; then
- mkdir ${installdir}/boot/zfs
- fi
- cp /boot/zfs/zpool.cache /${installdir}/boot/zfs/
- ${prg_zfs} set mountpoint=/ tank
- ${prg_zpool} set bootfs=tank/root tank
- fi
- }
- ################################################################################
- ################################################################################
- case "${1}" in
- ad[0-9]|da[0-9]|ada[0-9]|mirror/gm[0-9])
- if [ ! -e "/dev/${1}" ]; then
- echo "device ${1} not found!"
- exit 1
- fi
- find_options "${@}"
- find_mfsbsd
- check_options
- if [ ${zfs} = "yes" ]; then
- create_zfs_partitions "${1}"
- else
- create_ufs_partitions "${1}"
- fi
- download_needed_files
- install_freebsd
- if [ ${zfs} = "yes" ]; then
- configure_zfs_freebsd "${1}"
- else
- configure_ufs_freebsd "${1}"
- fi
- configure_freebsd_part2 "${1}"
- install_opt
- install_jail_normal
- install_jail_jroot
- configure_jail
- dismount_mfsbsd
- finished
- if [ `echo ${1} | wc -m` -gt 5 ]; then
- echo 'geom_mirror_load="YES"' >>/${installdir}/boot/loader.conf
- fi
- echo
- echo " --> Install finished <-- "
- echo " --> Rebooting the System, remove the CD/DVD please!"
- ;;
- --list | -l)
- echo "FreeBSD Installer version ${scriptversion} for FreeBSD ${freebsdversion}-${freebsdtype}"
- echo "============================================="
- echo "possible FreeBSD install devices are:"
- ls -1 /dev/da[0-9] /dev/ada[0-9] /dev/mirror/gm[0-9] 2>/dev/null | sed -e 's/\/dev\///g' -e 's/^/- /g'
- ;;
- --help | -h)
- cat <<__USAGE__
- FreeBSD Installer version ${scriptversion} for FreeBSD ${freebsdversion}-${freebsdtype}
- =======================================================================
- usage: ${0} { ada[0-9] | mirror/gm[0-9] | -l | -h }
- -----------------------------------------------------------------------
- { -l | --list } list possible install devices
- { -h | --help } this help
- install mode (default is normal)
- normal=/var 2GB | db-or-mail=/var 15GB | alix=/ complete disc
- { -i:normal | db-or-mail | alix }
- { --installmode:normal | db-or-mail | alix }
- -----------------------------------------------------------------------
- optional options:
- { -mj:jroot | --masterjail:jroot } one base for ALL jails
- { -mj:normal | --masterjail:normal } one base for ONE jail
- { -t | --tmpfs:yes } use tmpfs for /tmp
- { -z | --zfs:yes } use zfs as filesystem
- { -p | --ports:yes } install ports
- { -s | --source:yes } install source
- -----------------------------------------------------------------------
- example: ${0} ada0 -i:db-or-mail -t -s -mj:normal
- -----------------------------------------------------------------------
- __USAGE__
- ;;
- *)
- echo "usage: ${0} --help"
- echo "for --help"
- ;;
- esac
- exit 0