6 # Set to a list of packages to install.
7 export VM_EXTRA_PACKAGES="firstboot-freebsd-update firstboot-pkgs \
8 google-cloud-sdk panicmail sudo sysutils/py-google-compute-engine \
9 lang/python lang/python2 lang/python3"
11 # Set to a list of third-party software to enable in rc.conf(5).
12 export VM_RC_LIST="ntpd sshd growfs \
13 firstboot_pkgs firstboot_freebsd_update google_startup \
14 google_accounts_daemon google_clock_skew_daemon \
15 google_instance_setup google_network_daemon"
17 vm_extra_install_base() {
18 echo 'search google.internal' > ${DESTDIR}/etc/resolv.conf
19 echo 'nameserver 169.254.169.254' >> ${DESTDIR}/etc/resolv.conf
20 echo 'nameserver 8.8.8.8' >> ${DESTDIR}/etc/resolv.conf
23 vm_extra_pre_umount() {
24 # Enable growfs on every boot, not only the first, as as instance's disk can
25 # be enlarged post-creation
26 sed -i -e '/KEYWORD: firstboot/d' /etc/rc.d/growfs
28 cat << EOF >> ${DESTDIR}/etc/rc.conf
30 ifconfig_DEFAULT="SYNCDHCP mtu 1460"
31 ntpd_sync_on_start="YES"
32 # need to fill in something here
33 #firstboot_pkgs_list=""
34 panicmail_autosubmit="YES"
37 cat << EOF >> ${DESTDIR}/boot/loader.conf
42 console="comconsole,vidconsole"
44 kern.timecounter.hardware=ACPI-safe
49 echo '169.254.169.254 metadata.google.internal metadata' > \
53 cat << EOF > ${DESTDIR}/etc/ntp.conf
54 server metadata.google.internal iburst
56 restrict default kod nomodify notrap nopeer noquery
57 restrict -6 default kod nomodify notrap nopeer noquery
64 cat << EOF >> ${DESTDIR}/etc/syslog.conf
65 *.err;kern.warning;auth.notice;mail.crit /dev/console
68 cat << EOF >> ${DESTDIR}/etc/ssh/sshd_config
69 ChallengeResponseAuthentication no
72 AllowAgentForwarding no
73 ClientAliveInterval 420
76 cat << EOF >> ${DESTDIR}/etc/crontab
77 0 3 * * * root /usr/sbin/freebsd-update cron
80 cat << EOF >> ${DESTDIR}/etc/sysctl.conf
81 net.inet.icmp.drop_redirect=1
82 net.inet.ip.redirect=0
83 net.inet.tcp.blackhole=2
84 net.inet.udp.blackhole=1
85 kern.ipc.somaxconn=1024
86 debug.trace_on_panic=1
87 debug.debugger_on_panic=0
90 # To meet GCE marketplace requirements, extract the src.txz and
91 # ports.txz distributions to the target virtual machine disk image
92 # and fetch the sources for the third-party software installed on
94 if [ ! -c "${DESTDIR}/dev/null" ]; then
95 mkdir -p ${DESTDIR}/dev
96 mount -t devfs devfs ${DESTDIR}/dev
98 if [ -e "${DESTDIR}/../ftp/src.txz" ]; then
99 tar fxJ ${DESTDIR}/../ftp/src.txz -C ${DESTDIR}
101 if [ -e "${DESTDIR}/../ftp/ports.txz" ]; then
102 tar fxJ ${DESTDIR}/../ftp/ports.txz -C ${DESTDIR}
103 _INSTALLED_PACKAGES=$(chroot ${DESTDIR} pkg info -o -q -a)
104 for PACKAGE in ${_INSTALLED_PACKAGES}; do
106 make -C /usr/ports/${PACKAGE} fetch
109 if [ -c "${DESTDIR}/dev/null" ]; then
110 umount_loop ${DESTDIR}/dev
113 ## XXX: Verify this is needed. I do not see this requirement
114 ## in the docs, and it impairs the ability to boot-test a copy
115 ## of the image prior to packaging for upload to GCE.
116 #sed -E -i '' 's/^([^#].*[[:space:]])on/\1off/' ${DESTDIR}/etc/ttys
118 touch ${DESTDIR}/firstboot
120 rm -f ${DESTDIR}/etc/resolv.conf