export VMSIZE=20g
export VM_EXTRA_PACKAGES="${VM_EXTRA_PACKAGES} firstboot-freebsd-update \
firstboot-pkgs google-cloud-sdk panicmail sudo \
sysutils/py-google-compute-engine lang/python \
lang/python3"
export VM_RC_LIST="ntpd sshd growfs \
firstboot_pkgs firstboot_freebsd_update google_startup \
google_accounts_daemon google_clock_skew_daemon \
google_instance_setup google_network_daemon"
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() {
local DEVFSISOURS
sed -i -e '/KEYWORD: firstboot/d' /etc/rc.d/growfs
cat << EOF >> ${DESTDIR}/etc/rc.conf
dumpdev="AUTO"
ifconfig_DEFAULT="SYNCDHCP mtu 1460"
ntpd_sync_on_start="YES"
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
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
KbdInteractiveAuthentication no
X11Forwarding no
AcceptEnv LANG
AllowAgentForwarding no
ClientAliveInterval 420
EOF
cat << EOF >> ${DESTDIR}/etc/crontab
0 3 * * * root /usr/sbin/freebsd-update cron
EOF
cat << EOF >> ${DESTDIR}/etc/sysctl.conf
net.inet.icmp.drop_redirect=1
net.inet.ip.redirect=0
kern.ipc.soacceptqueue=1024
debug.trace_on_panic=1
debug.debugger_on_panic=0
EOF
if [ ! -c "${DESTDIR}/dev/null" ]; then
DEVFSISOURS=1
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 [ "$DEVFSISOURS" = "1" ]; then
umount_loop ${DESTDIR}/dev
fi
touch ${DESTDIR}/firstboot
return 0
}
vm_emulation_cleanup() {
if [ -n "${QEMUSTATIC}" ]; then
rm -f ${DESTDIR}/${EMULATOR}
fi
umount_loop ${DESTDIR}/dev
return 0
}