[Midnightbsd-cvs] src [11849] trunk/release/tools: add the configs for future use
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Fri Jul 13 08:35:28 EDT 2018
Revision: 11849
http://svnweb.midnightbsd.org/src/?rev=11849
Author: laffer1
Date: 2018-07-13 08:35:27 -0400 (Fri, 13 Jul 2018)
Log Message:
-----------
add the configs for future use
Added Paths:
-----------
trunk/release/tools/
trunk/release/tools/arm.subr
trunk/release/tools/azure.conf
trunk/release/tools/ec2.conf
trunk/release/tools/gce.conf
trunk/release/tools/openstack.conf
trunk/release/tools/vagrant-virtualbox.conf
trunk/release/tools/vagrant-vmware.conf
trunk/release/tools/vagrant.conf
trunk/release/tools/vmimage.subr
Added: trunk/release/tools/arm.subr
===================================================================
--- trunk/release/tools/arm.subr (rev 0)
+++ trunk/release/tools/arm.subr 2018-07-13 12:35:27 UTC (rev 11849)
@@ -0,0 +1,136 @@
+#!/bin/sh
+#-
+# Copyright (c) 2015-2017 The FreeBSD Foundation
+# All rights reserved.
+#
+# Portions of this software were developed by Glen Barber
+# under sponsorship from the FreeBSD Foundation.
+#
+# 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.
+#
+# Common subroutines used to build arm SD card images.
+#
+# $MidnightBSD$
+#
+
+cleanup() {
+ if [ -c "${DESTDIR}/dev/null" ]; then
+ umount_loop ${DESTDIR}/dev 2>/dev/null
+ fi
+ umount_loop ${DESTDIR}
+ if [ ! -z "${mddev}" ]; then
+ mdconfig -d -u ${mddev}
+ fi
+
+ return 0
+}
+
+umount_loop() {
+ DIR=$1
+ i=0
+ sync
+ while ! umount ${DIR}; do
+ i=$(( $i + 1 ))
+ if [ $i -ge 10 ]; then
+ # This should never happen. But, it has happened.
+ echo "Cannot umount(8) ${DIR}"
+ echo "Something has gone horribly wrong."
+ return 1
+ fi
+ sleep 1
+ done
+
+ return 0
+}
+
+arm_create_disk() {
+ # Create the target raw file and temporary work directory.
+ chroot ${CHROOTDIR} gpart create -s ${PART_SCHEME} ${mddev}
+ chroot ${CHROOTDIR} gpart add -t '!12' -a 512k -s ${FAT_SIZE} ${mddev}
+ chroot ${CHROOTDIR} gpart set -a active -i 1 ${mddev}
+ chroot ${CHROOTDIR} newfs_msdos -L msdosboot -F ${FAT_TYPE} /dev/${mddev}s1
+ chroot ${CHROOTDIR} gpart add -t midnightbsd ${mddev}
+ chroot ${CHROOTDIR} gpart create -s bsd ${mddev}s2
+ chroot ${CHROOTDIR} gpart add -t mnbsd-ufs -a 64k /dev/${mddev}s2
+ chroot ${CHROOTDIR} newfs -U -L rootfs /dev/${mddev}s2a
+
+ return 0
+}
+
+arm_create_user() {
+ # Create a default user account 'midnightbsd' with the password 'midnightbsd',
+ # and set the default password for the 'root' user to 'root'.
+ chroot ${CHROOTDIR} /usr/sbin/pw -R ${DESTDIR} \
+ groupadd midnightbsd -g 1001
+ chroot ${CHROOTDIR} mkdir -p ${DESTDIR}/home/midnightbsd
+ chroot ${CHROOTDIR} /usr/sbin/pw -R ${DESTDIR} \
+ useradd midnightbsd \
+ -m -M 0755 -w yes -n midnightbsd -u 1001 -g 1001 -G 0 \
+ -c 'MidnightBSD User' -d '/home/midnightbsd' -s '/bin/csh'
+ chroot ${CHROOTDIR} /usr/sbin/pw -R ${DESTDIR} \
+ usermod root -w yes
+
+ return 0
+}
+
+arm_install_base() {
+ chroot ${CHROOTDIR} mount /dev/${mddev}s2a ${DESTDIR}
+ eval chroot ${CHROOTDIR} make -C ${WORLDDIR} \
+ TARGET=${EMBEDDED_TARGET} \
+ TARGET_ARCH=${EMBEDDED_TARGET_ARCH} \
+ DESTDIR=${DESTDIR} KERNCONF=${KERNEL} \
+ installworld installkernel distribution
+ chroot ${CHROOTDIR} mkdir -p ${DESTDIR}/boot/msdos
+
+ arm_create_user
+
+ echo '# Custom /etc/fstab for MidnightBSD embedded images' \
+ > ${CHROOTDIR}/${DESTDIR}/etc/fstab
+ echo "/dev/ufs/rootfs / ufs rw 1 1" \
+ >> ${CHROOTDIR}/${DESTDIR}/etc/fstab
+ echo "/dev/msdosfs/MSDOSBOOT /boot/msdos msdosfs rw,noatime 0 0" \
+ >> ${CHROOTDIR}/${DESTDIR}/etc/fstab
+ echo "tmpfs /tmp tmpfs rw,mode=1777,size=30m 0 0" \
+ >> ${CHROOTDIR}/${DESTDIR}/etc/fstab
+
+ local hostname
+ hostname="$(echo ${KERNEL} | tr '[:upper:]' '[:lower:]')"
+ echo "hostname=\"${hostname}\"" > ${CHROOTDIR}/${DESTDIR}/etc/rc.conf
+ echo 'ifconfig_DEFAULT="DHCP"' >> ${CHROOTDIR}/${DESTDIR}/etc/rc.conf
+ echo 'sshd_enable="YES"' >> ${CHROOTDIR}/${DESTDIR}/etc/rc.conf
+ echo 'sendmail_enable="NONE"' >> ${CHROOTDIR}/${DESTDIR}/etc/rc.conf
+ echo 'sendmail_submit_enable="NO"' >> ${CHROOTDIR}/${DESTDIR}/etc/rc.conf
+ echo 'sendmail_outbound_enable="NO"' >> ${CHROOTDIR}/${DESTDIR}/etc/rc.conf
+ echo 'sendmail_msp_queue_enable="NO"' >> ${CHROOTDIR}/${DESTDIR}/etc/rc.conf
+ echo 'growfs_enable="YES"' >> ${CHROOTDIR}/${DESTDIR}/etc/rc.conf
+
+ sync
+ umount_loop ${CHROOTDIR}/${DESTDIR}
+
+ return 0
+}
+
+arm_install_uboot() {
+ # Override in the arm/KERNEL.conf file.
+
+ return 0
+}
Property changes on: trunk/release/tools/arm.subr
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: trunk/release/tools/azure.conf
===================================================================
--- trunk/release/tools/azure.conf (rev 0)
+++ trunk/release/tools/azure.conf 2018-07-13 12:35:27 UTC (rev 11849)
@@ -0,0 +1,29 @@
+#!/bin/sh
+#
+# $MidnightBSD$
+#
+
+# Set to a list of packages to install.
+# Example:
+#export VM_EXTRA_PACKAGES="www/apache24"
+export VM_EXTRA_PACKAGES="sysutils/azure-agent"
+
+# Set to a list of third-party software to enable in rc.conf(5).
+# Example:
+#export VM_RC_LIST="apache24"
+export VM_RC_LIST=
+
+vm_extra_pre_umount() {
+ chroot ${DESTDIR} ln -s /usr/local/sbin/waagent /usr/sbin/waagent
+ chroot ${DESTDIR} /usr/local/sbin/waagent -verbose -install
+ yes | chroot ${DESTDIR} /usr/local/sbin/waagent -deprovision
+ echo 'sshd_enable="YES"' >> ${DESTDIR}/etc/rc.conf
+ echo 'ifconfig_hn0="SYNCDHCP"' >> ${DESTDIR}/etc/rc.conf
+ echo 'waagent_enable="YES"' >> ${DESTDIR}/etc/rc.conf
+ echo 'console="comconsole vidconsole"' >> ${DESTDIR}/boot/loader.conf
+ echo 'comconsole_speed="115200"' >> ${DESTDIR}/boot/loader.conf
+
+ rm -f ${DESTDIR}/etc/resolv.conf
+
+ return 0
+}
Property changes on: trunk/release/tools/azure.conf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/release/tools/ec2.conf
===================================================================
--- trunk/release/tools/ec2.conf (rev 0)
+++ trunk/release/tools/ec2.conf 2018-07-13 12:35:27 UTC (rev 11849)
@@ -0,0 +1,88 @@
+#!/bin/sh
+#
+# $MidnightBSD$
+#
+
+# Packages to install into the image we're creating. This is a deliberately
+# minimalist set, providing only the packages necessary to bootstrap further
+# package installation as specified via EC2 user-data.
+export VM_EXTRA_PACKAGES="ec2-scripts firstboot-midnightbsd-update firstboot-pkgs"
+
+# Set to a list of third-party software to enable in rc.conf(5).
+export VM_RC_LIST="ec2_configinit ec2_fetchkey ec2_ephemeralswap ec2_loghostkey firstboot_midnightbsd_update firstboot_pkgs"
+
+# Build with a 1.5 GB UFS partition; the growfs rc.d script will expand
+# the partition to fill the root disk after the EC2 instance is launched.
+# Note that if this is set to <N>G, we will end up with an <N+1> GB disk
+# image since VMSIZE is the size of the UFS partition, not the disk which
+# it resides within.
+export VMSIZE=1536M
+
+# No swap space; the ec2_ephemeralswap rc.d script will allocate swap
+# space on EC2 ephemeral disks. (If they exist -- the T2 low-cost instances
+# and the C4 compute-optimized instances don't have ephemeral disks. But
+# it would be silly to bloat the image and increase costs for every instance
+# just for those two families, especially since instances ranging in size
+# from 1 GB of RAM to 60 GB of RAM would need different sizes of swap space
+# anyway.)
+export NOSWAP=YES
+
+vm_extra_pre_umount() {
+ # The firstboot_pkgs rc.d script will download the repository
+ # catalogue and install or update pkg when the instance first
+ # launches, so these files would just be replaced anyway; removing
+ # them from the image allows it to boot faster.
+ chroot ${DESTDIR} env ASSUME_ALWAYS_YES=yes \
+ /usr/sbin/pkg delete -f -y pkg
+ rm ${DESTDIR}/var/db/pkg/repo-*.sqlite
+
+ # The size of the EC2 root disk can be configured at instance launch
+ # time; expand our filesystem to fill the disk.
+ echo 'growfs_enable="YES"' >> ${DESTDIR}/etc/rc.conf
+
+ # EC2 instances use DHCP to get their network configuration.
+ echo 'ifconfig_DEFAULT="SYNCDHCP"' >> ${DESTDIR}/etc/rc.conf
+
+ # Unless the system has been configured via EC2 user-data, the user
+ # will need to SSH in to do anything.
+ echo 'sshd_enable="YES"' >> ${DESTDIR}/etc/rc.conf
+
+ # The AWS CLI tools are generally useful, and small enough that they
+ # will download quickly; but users will often override this setting
+ # via EC2 user-data.
+ echo 'firstboot_pkgs_list="awscli"' >> ${DESTDIR}/etc/rc.conf
+
+ # The EC2 console is output-only, so while printing a backtrace can
+ # be useful, there's no point dropping into a debugger or waiting
+ # for a keypress.
+ echo 'debug.trace_on_panic=1' >> ${DESTDIR}/etc/sysctl.conf
+ echo 'debug.debugger_on_panic=0' >> ${DESTDIR}/etc/sysctl.conf
+ echo 'kern.panic_reboot_wait_time=0' >> ${DESTDIR}/etc/sysctl.conf
+
+ # The console is not interactive, so we might as well boot quickly.
+ echo 'autoboot_delay="-1"' >> ${DESTDIR}/boot/loader.conf
+ echo 'beastie_disable="YES"' >> ${DESTDIR}/boot/loader.conf
+
+ # EC2 has two consoles: An emulated serial port ("system log"),
+ # which has been present since 2006; and a VGA console ("instance
+ # screenshot") which was introduced in 2016.
+ echo 'boot_multicons="YES"' >> ${DESTDIR}/boot/loader.conf
+
+ # Some older EC2 hardware used a version of Xen with a bug in its
+ # emulated serial port. It is not clear if EC2 still has any such
+ # nodes, but apply the workaround just in case.
+ echo 'hw.broken_txfifo="1"' >> ${DESTDIR}/boot/loader.conf
+
+ # The first time the AMI boots, the installed "first boot" scripts
+ # should be allowed to run:
+ # * ec2_configinit (download and process EC2 user-data)
+ # * ec2_fetchkey (arrange for SSH using the EC2-provided public key)
+ # * growfs (expand the filesystem to fill the provided disk)
+ # * firstboot_midnightbsd_update (install critical updates)
+ # * firstboot_pkgs (install packages)
+ touch ${DESTDIR}/firstboot
+
+ rm -f ${DESTDIR}/etc/resolv.conf
+
+ return 0
+}
Property changes on: trunk/release/tools/ec2.conf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/release/tools/gce.conf
===================================================================
--- trunk/release/tools/gce.conf (rev 0)
+++ trunk/release/tools/gce.conf 2018-07-13 12:35:27 UTC (rev 11849)
@@ -0,0 +1,121 @@
+#!/bin/sh
+#
+# $MidnightBSD$
+#
+
+# Set to a list of packages to install.
+export VM_EXTRA_PACKAGES="firstboot-midnightbsd-update firstboot-pkgs \
+ google-cloud-sdk panicmail sudo firstboot-growfs \
+ sysutils/py-google-compute-engine"
+
+# Set to a list of third-party software to enable in rc.conf(5).
+export VM_RC_LIST="ntpd sshd firstboot_growfs \
+ firstboot_pkgs firstboot_midnightbsd_update google_startup \
+ google_accounts_daemon google_clock_skew_daemon \
+ google_instance_setup google_ip_forwarding_daemon \
+ google_network_setup"
+
+vm_extra_install_base() {
+ echo 'search google.internal' > ${DESTDIR}/etc/resolv.conf
+ echo 'nameserver 169.254.169.254' >> ${DESTDIR}/etc/resolv.conf
+ echo 'nameserver 8.8.8.8' >> ${DESTDIR}/etc/resolv.conf
+}
+
+vm_extra_pre_umount() {
+ cat << EOF >> ${DESTDIR}/etc/rc.conf
+dumpdev="AUTO"
+ifconfig_DEFAULT="SYNCDHCP mtu 1460"
+ntpd_sync_on_start="YES"
+# need to fill in something here
+#firstboot_pkgs_list=""
+panicmail_autosubmit="YES"
+EOF
+
+ cat << EOF >> ${DESTDIR}/boot/loader.conf
+autoboot_delay="-1"
+beastie_disable="YES"
+loader_logo="none"
+hw.memtest.tests="0"
+console="comconsole,vidconsole"
+hw.vtnet.mq_disable=1
+kern.timecounter.hardware=ACPI-safe
+aesni_load="YES"
+nvme_load="YES"
+EOF
+
+ echo '169.254.169.254 metadata.google.internal metadata' > \
+ ${DESTDIR}/etc/hosts
+
+ # overwrite ntp.conf
+ cat << EOF > ${DESTDIR}/etc/ntp.conf
+server metadata.google.internal iburst
+
+restrict default kod nomodify notrap nopeer noquery
+restrict -6 default kod nomodify notrap nopeer noquery
+
+restrict 127.0.0.1
+restrict -6 ::1
+restrict 127.127.1.0
+EOF
+
+ cat << EOF >> ${DESTDIR}/etc/syslog.conf
+*.err;kern.warning;auth.notice;mail.crit /dev/console
+EOF
+
+ cat << EOF >> ${DESTDIR}/etc/ssh/sshd_config
+ChallengeResponseAuthentication no
+X11Forwarding no
+AcceptEnv LANG
+Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc
+AllowAgentForwarding no
+ClientAliveInterval 420
+EOF
+
+ cat << EOF >> ${DESTDIR}/etc/crontab
+0 3 * * * root /usr/sbin/midnightbsd-update cron
+EOF
+
+ cat << EOF >> ${DESTDIR}/etc/sysctl.conf
+net.inet.icmp.drop_redirect=1
+net.inet.ip.redirect=0
+net.inet.tcp.blackhole=2
+net.inet.udp.blackhole=1
+kern.ipc.somaxconn=1024
+debug.trace_on_panic=1
+debug.debugger_on_panic=0
+EOF
+
+ # To meet GCE marketplace requirements, extract the src.txz and
+ # ports.txz distributions to the target virtual machine disk image
+ # and fetch the sources for the third-party software installed on
+ # the image.
+ if [ ! -c "${DESTDIR}/dev/null" ]; then
+ mkdir -p ${DESTDIR}/dev
+ mount -t devfs devfs ${DESTDIR}/dev
+ fi
+ if [ -e "${DESTDIR}/../ftp/src.txz" ]; then
+ tar fxJ ${DESTDIR}/../ftp/src.txz -C ${DESTDIR}
+ fi
+ if [ -e "${DESTDIR}/../ftp/ports.txz" ]; then
+ tar fxJ ${DESTDIR}/../ftp/ports.txz -C ${DESTDIR}
+ _INSTALLED_PACKAGES=$(chroot ${DESTDIR} pkg info -o -q -a)
+ for PACKAGE in ${_INSTALLED_PACKAGES}; do
+ chroot ${DESTDIR} \
+ make -C /usr/ports/${PACKAGE} fetch
+ done
+ fi
+ if [ -c "${DESTDIR}/dev/null" ]; then
+ umount_loop ${DESTDIR}/dev
+ fi
+
+ ## XXX: Verify this is needed. I do not see this requirement
+ ## in the docs, and it impairs the ability to boot-test a copy
+ ## of the image prior to packaging for upload to GCE.
+ #sed -E -i '' 's/^([^#].*[[:space:]])on/\1off/' ${DESTDIR}/etc/ttys
+
+ touch ${DESTDIR}/firstboot
+
+ rm -f ${DESTDIR}/etc/resolv.conf
+
+ return 0
+}
Property changes on: trunk/release/tools/gce.conf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/release/tools/openstack.conf
===================================================================
--- trunk/release/tools/openstack.conf (rev 0)
+++ trunk/release/tools/openstack.conf 2018-07-13 12:35:27 UTC (rev 11849)
@@ -0,0 +1,25 @@
+#!/bin/sh
+#
+# $MidnightBSD$
+#
+
+# Set to a list of packages to install.
+export VM_EXTRA_PACKAGES="net/cloud-init devel/py-pbr devel/py-iso8601 \
+ net/py-eventlet net/py-netaddr comms/py-serial devel/py-six \
+ devel/py-babel net/py-oauth net/py-netifaces"
+
+# Set to a list of third-party software to enable in rc.conf(5).
+export VM_RC_LIST="cloudinit"
+
+vm_extra_pre_umount() {
+ echo 'sshd_enable="YES"' >> ${DESTDIR}/etc/rc.conf
+ echo 'ifconfig_DEFAULT="SYNCDHCP"' >> ${DESTDIR}/etc/rc.conf
+
+ # Openstack wants sudo(8) usable by default without a password.
+ echo 'ALL ALL=(ALL) NOPASSWD:ALL' >> \
+ ${DESTDIR}/usr/local/etc/sudoers.d/cloud-init
+
+ rm -f ${DESTDIR}/etc/resolv.conf
+
+ return 0
+}
Property changes on: trunk/release/tools/openstack.conf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/release/tools/vagrant-virtualbox.conf
===================================================================
--- trunk/release/tools/vagrant-virtualbox.conf (rev 0)
+++ trunk/release/tools/vagrant-virtualbox.conf 2018-07-13 12:35:27 UTC (rev 11849)
@@ -0,0 +1,19 @@
+#!/bin/sh
+#
+# $MidnightBSD$
+#
+
+. ${WORLDDIR}/release/tools/vagrant.conf
+
+export VM_EXTRA_PACKAGES="${VM_EXTRA_PACKAGES} virtualbox-ose-additions"
+
+vm_extra_pre_umount () {
+ # VirtualBox first boot pkgs
+ echo 'firstboot_pkgs_list="sudo rsync virtualbox-ose-additions"' >> ${DESTDIR}/etc/rc.conf
+ echo 'vboxguest_enable="YES"' >> ${DESTDIR}/etc/rc.conf
+ echo 'vboxservice_enable="YES"' >> ${DESTDIR}/etc/rc.conf
+
+ # Setup the Vagrant common items
+ vagrant_common
+ rm -f ${DESTDIR}/etc/resolv.conf
+}
Property changes on: trunk/release/tools/vagrant-virtualbox.conf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/release/tools/vagrant-vmware.conf
===================================================================
--- trunk/release/tools/vagrant-vmware.conf (rev 0)
+++ trunk/release/tools/vagrant-vmware.conf 2018-07-13 12:35:27 UTC (rev 11849)
@@ -0,0 +1,23 @@
+#!/bin/sh
+#
+# $MidnightBSD$
+#
+
+. ${WORLDDIR}/release/tools/vagrant.conf
+
+export VM_EXTRA_PACKAGES="${VM_EXTRA_PACKAGES} open-vm-tools-nox11"
+
+vm_extra_pre_umount () {
+ # VMWare first boot pkgs
+ echo 'firstboot_pkgs_list="sudo rsync open-vm-tools-nox11"' >> ${DESTDIR}/etc/rc.conf
+
+ echo 'vmware_guest_vmblock_enable="YES"' >> ${DESTDIR}/etc/rc.conf
+ echo 'vmware_guest_vmhgfs_enable="YES"' >> ${DESTDIR}/etc/rc.conf
+ echo 'vmware_guest_vmmemctl_enable="YES"' >> ${DESTDIR}/etc/rc.conf
+ echo 'vmware_guest_vmxnet_enable="YES"' >> ${DESTDIR}/etc/rc.conf
+ echo 'vmware_guestd_enable="YES"' >> ${DESTDIR}/etc/rc.conf
+
+ # Setup the Vagrant common items
+ vagrant_common
+ rm -f ${DESTDIR}/etc/resolv.conf
+}
Property changes on: trunk/release/tools/vagrant-vmware.conf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/release/tools/vagrant.conf
===================================================================
--- trunk/release/tools/vagrant.conf (rev 0)
+++ trunk/release/tools/vagrant.conf 2018-07-13 12:35:27 UTC (rev 11849)
@@ -0,0 +1,75 @@
+#!/bin/sh
+#
+# $MidnightBSD$
+#
+
+# Packages to install into the image we're creating. This is a deliberately
+# minimalist set, providing only the packages necessary to bootstrap.
+export VM_EXTRA_PACKAGES="firstboot-midnightbsd-update firstboot-pkgs"
+
+# Set to a list of third-party software to enable in rc.conf(5).
+export VM_RC_LIST="firstboot_midnightbsd_update firstboot_pkgs"
+
+vagrant_common () {
+ # The firstboot_pkgs rc.d script will download the repository
+ # catalogue and install or update pkg when the instance first
+ # launches, so these files would just be replaced anyway; removing
+ # them from the image allows it to boot faster.
+ env ASSUME_ALWAYS_YES=yes pkg -c ${DESTDIR} clean -y -a
+ env ASSUME_ALWAYS_YES=yes pkg -c ${DESTDIR} delete -f -y pkg
+ rm ${DESTDIR}/var/db/pkg/repo-*.sqlite
+
+ # Vagrant instances use DHCP to get their network configuration.
+ echo 'ifconfig_DEFAULT="SYNCDHCP"' >> ${DESTDIR}/etc/rc.conf
+
+ # Enable sshd by default
+ echo 'sshd_enable="YES"' >> ${DESTDIR}/etc/rc.conf
+ # Disable DNS lookups by default to make SSH connect quickly
+ echo 'UseDNS no' >> ${DESTDIR}/etc/ssh/sshd_config
+
+ # Disable sendmail
+ echo 'sendmail_enable="NO"' >> ${DESTDIR}/etc/rc.conf
+ echo 'sendmail_submit_enable="NO"' >> ${DESTDIR}/etc/rc.conf
+ echo 'sendmail_outbound_enable="NO"' >> ${DESTDIR}/etc/rc.conf
+ echo 'sendmail_msp_queue_enable="NO"' >> ${DESTDIR}/etc/rc.conf
+
+ # Create the vagrant user with a password of vagrant
+ /usr/sbin/pw -R ${DESTDIR} \
+ groupadd vagrant -g 1001
+ chroot ${DESTDIR} mkdir -p /home/vagrant
+ /usr/sbin/pw -R ${DESTDIR} \
+ useradd vagrant \
+ -m -M 0755 -w yes -n vagrant -u 1001 -g 1001 -G 0 \
+ -c 'Vagrant User' -d '/home/vagrant' -s '/bin/csh'
+
+ # Change root's password to vagrant
+ echo 'vagrant' | /usr/sbin/pw -R ${DESTDIR} \
+ usermod root -h 0
+
+ # Configure sudo to allow the vagrant user
+ echo 'vagrant ALL=(ALL) NOPASSWD: ALL' >> ${DESTDIR}/usr/local/etc/sudoers
+
+ # Configure the vagrant ssh key
+ mkdir ${DESTDIR}/home/vagrant/.ssh
+ chmod 700 ${DESTDIR}/home/vagrant/.ssh
+ echo "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key" > ${DESTDIR}/home/vagrant/.ssh/authorized_keys
+ chown -R 1001 ${DESTDIR}/home/vagrant/.ssh
+ chmod 600 ${DESTDIR}/home/vagrant/.ssh/authorized_keys
+
+ # Reboot quickly, Don't wait at the panic screen
+ echo 'debug.trace_on_panic=1' >> ${DESTDIR}/etc/sysctl.conf
+ echo 'debug.debugger_on_panic=0' >> ${DESTDIR}/etc/sysctl.conf
+ echo 'kern.panic_reboot_wait_time=0' >> ${DESTDIR}/etc/sysctl.conf
+
+ # The console is not interactive, so we might as well boot quickly.
+ echo 'autoboot_delay="-1"' >> ${DESTDIR}/boot/loader.conf
+
+ # The first time the VM boots, the installed "first boot" scripts
+ # should be allowed to run:
+ # * growfs (expand the filesystem to fill the provided disk)
+ # * firstboot_midnightbsd_update (install critical updates)
+ # * firstboot_pkgs (install packages)
+ touch ${DESTDIR}/firstboot
+
+ return 0
+}
Property changes on: trunk/release/tools/vagrant.conf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/release/tools/vmimage.subr
===================================================================
--- trunk/release/tools/vmimage.subr (rev 0)
+++ trunk/release/tools/vmimage.subr 2018-07-13 12:35:27 UTC (rev 11849)
@@ -0,0 +1,247 @@
+#!/bin/sh
+#
+# $MidnightBSD$
+#
+#
+# Common functions for virtual machine image build scripts.
+#
+
+export PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
+trap "cleanup" INT QUIT TRAP ABRT TERM
+
+write_partition_layout() {
+ if [ -z "${NOSWAP}" ]; then
+ SWAPOPT="-p mnbsd-swap/swapfs::${SWAPSIZE}"
+ fi
+
+ _OBJDIR="$(make -C ${WORLDDIR} -V .OBJDIR)"
+ _OBJDIR="$(realpath ${_OBJDIR})"
+ if [ -d "${_OBJDIR%%/usr/src}/${TARGET}.${TARGET_ARCH}" ]; then
+ BOOTFILES="/${_OBJDIR%%/usr/src}/${TARGET}.${TARGET_ARCH}/usr/src/sys/boot"
+ else
+ BOOTFILES="/${_OBJDIR}/sys/boot"
+ fi
+
+ case "${TARGET}:${TARGET_ARCH}" in
+ amd64:amd64 | i386:i386)
+ mkimg -s gpt -f ${VMFORMAT} \
+ -b ${BOOTFILES}/i386/pmbr/pmbr \
+ -p mnbsd-boot/bootfs:=${BOOTFILES}/i386/gptboot/gptboot \
+ ${SWAPOPT} \
+ -p mnbsd-ufs/rootfs:=${VMBASE} \
+ -o ${VMIMAGE}
+ ;;
+ powerpc:powerpc*)
+ mkimg -s apm -f ${VMFORMAT} \
+ -p apple-boot/bootfs:=${BOOTFILES}/powerpc/boot1.chrp/boot1.hfs \
+ ${SWAPOPT} \
+ -p mnbsd-ufs/rootfs:=${VMBASE} \
+ -o ${VMIMAGE}
+ ;;
+ *)
+ # ENOTSUPP
+ return 1
+ ;;
+ esac
+
+ return 0
+}
+
+err() {
+ printf "${@}\n"
+ cleanup
+ return 1
+}
+
+cleanup() {
+ if [ -c "${DESTDIR}/dev/null" ]; then
+ umount_loop ${DESTDIR}/dev 2>/dev/null
+ fi
+ umount_loop ${DESTDIR}
+ if [ ! -z "${mddev}" ]; then
+ mdconfig -d -u ${mddev}
+ fi
+
+ return 0
+}
+
+vm_create_base() {
+ # Creates the UFS root filesystem for the virtual machine disk,
+ # written to the formatted disk image with mkimg(1).
+
+ mkdir -p ${DESTDIR}
+ truncate -s ${VMSIZE} ${VMBASE}
+ mddev=$(mdconfig -f ${VMBASE})
+ newfs /dev/${mddev}
+ mount /dev/${mddev} ${DESTDIR}
+
+ return 0
+}
+
+vm_copy_base() {
+ # Creates a new UFS root filesystem and copies the contents of the
+ # current root filesystem into it. This produces a "clean" disk
+ # image without any remnants of files which were created temporarily
+ # during image-creation and have since been deleted (e.g., downloaded
+ # package archives).
+
+ mkdir -p ${DESTDIR}/old
+ mdold=$(mdconfig -f ${VMBASE})
+ mount /dev/${mdold} ${DESTDIR}/old
+
+ truncate -s ${VMSIZE} ${VMBASE}.tmp
+ mkdir -p ${DESTDIR}/new
+ mdnew=$(mdconfig -f ${VMBASE}.tmp)
+ newfs /dev/${mdnew}
+ mount /dev/${mdnew} ${DESTDIR}/new
+
+ tar -cf- -C ${DESTDIR}/old . | tar -xUf- -C ${DESTDIR}/new
+
+ umount_loop /dev/${mdold}
+ rmdir ${DESTDIR}/old
+ mdconfig -d -u ${mdold}
+
+ umount_loop /dev/${mdnew}
+ rmdir ${DESTDIR}/new
+ tunefs -n enable /dev/${mdnew}
+ mdconfig -d -u ${mdnew}
+ mv ${VMBASE}.tmp ${VMBASE}
+}
+
+vm_install_base() {
+ # Installs the BSD userland/kernel to the virtual machine disk.
+
+ cd ${WORLDDIR} && \
+ make DESTDIR=${DESTDIR} \
+ installworld installkernel distribution || \
+ err "\n\nCannot install the base system to ${DESTDIR}."
+
+ # Bootstrap etcupdate(8) and mergemaster(8) databases.
+ mkdir -p ${DESTDIR}/var/db/etcupdate
+ etcupdate extract -B \
+ -M "TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH}" \
+ -s ${WORLDDIR} -d ${DESTDIR}/var/db/etcupdate
+ sh ${WORLDDIR}/release/scripts/mm-mtree.sh -m ${WORLDDIR} \
+ -F "TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH}" \
+ -D ${DESTDIR}
+
+ echo '# Custom /etc/fstab for BSD VM images' \
+ > ${DESTDIR}/etc/fstab
+ echo '/dev/gpt/rootfs / ufs rw 1 1' \
+ >> ${DESTDIR}/etc/fstab
+ if [ -z "${NOSWAP}" ]; then
+ echo '/dev/gpt/swapfs none swap sw 0 0' \
+ >> ${DESTDIR}/etc/fstab
+ fi
+
+ local hostname
+ hostname="$(echo $(uname -o) | tr '[:upper:]' '[:lower:]')"
+ echo "hostname=\"${hostname}\"" >> ${DESTDIR}/etc/rc.conf
+
+ mkdir -p ${DESTDIR}/dev
+ mount -t devfs devfs ${DESTDIR}/dev
+ chroot ${DESTDIR} /usr/bin/newaliases
+ chroot ${DESTDIR} /etc/rc.d/ldconfig forcestart
+ umount_loop ${DESTDIR}/dev
+
+ cp /etc/resolv.conf ${DESTDIR}/etc/resolv.conf
+
+ return 0
+}
+
+vm_extra_install_base() {
+ # Prototype. When overridden, runs extra post-installworld commands
+ # as needed, based on the target virtual machine image or cloud
+ # provider image target.
+
+ return 0
+}
+
+vm_extra_enable_services() {
+ if [ ! -z "${VM_RC_LIST}" ]; then
+ for _rcvar in ${VM_RC_LIST}; do
+ echo ${_rcvar}_enable="YES" >> ${DESTDIR}/etc/rc.conf
+ done
+ fi
+
+ if [ -z "${VMCONFIG}" -o -c "${VMCONFIG}" ]; then
+ echo 'ifconfig_DEFAULT="DHCP inet6 accept_rtadv"' >> \
+ ${DESTDIR}/etc/rc.conf
+ fi
+
+ return 0
+}
+
+vm_extra_install_packages() {
+ if [ -z "${VM_EXTRA_PACKAGES}" ]; then
+ return 0
+ fi
+ mkdir -p ${DESTDIR}/dev
+ mount -t devfs devfs ${DESTDIR}/dev
+ chroot ${DESTDIR} env ASSUME_ALWAYS_YES=yes \
+ /usr/sbin/pkg bootstrap -y
+ chroot ${DESTDIR} env ASSUME_ALWAYS_YES=yes \
+ /usr/sbin/pkg install -y ${VM_EXTRA_PACKAGES}
+ umount_loop ${DESTDIR}/dev
+
+ return 0
+}
+
+vm_extra_install_ports() {
+ # Prototype. When overridden, installs additional mports within the
+ # virtual machine environment.
+
+ return 0
+}
+
+vm_extra_pre_umount() {
+ # Prototype. When overridden, performs additional tasks within the
+ # virtual machine environment prior to unmounting the filesystem.
+ # Note: When overriding this function, removing resolv.conf in the
+ # disk image must be included.
+
+ rm -f ${DESTDIR}/etc/resolv.conf
+ return 0
+}
+
+vm_extra_pkg_rmcache() {
+ if [ -e ${DESTDIR}/usr/local/sbin/pkg ]; then
+ chroot ${DESTDIR} env ASSUME_ALWAYS_YES=yes \
+ /usr/local/sbin/pkg clean -y -a
+ fi
+
+ return 0
+}
+
+umount_loop() {
+ DIR=$1
+ i=0
+ sync
+ while ! umount ${DIR}; do
+ i=$(( $i + 1 ))
+ if [ $i -ge 10 ]; then
+ # This should never happen. But, it has happened.
+ echo "Cannot umount(8) ${DIR}"
+ echo "Something has gone horribly wrong."
+ return 1
+ fi
+ sleep 1
+ done
+
+ return 0
+}
+
+vm_create_disk() {
+ echo "Creating image... Please wait."
+ echo
+
+ write_partition_layout || return 1
+
+ return 0
+}
+
+vm_extra_create_disk() {
+
+ return 0
+}
+
Property changes on: trunk/release/tools/vmimage.subr
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
More information about the Midnightbsd-cvs
mailing list