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