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