gce.conf revision 331363
1#!/bin/sh
2#
3# $FreeBSD: stable/10/release/tools/gce.conf 331363 2018-03-22 17:46:38Z gjb $
4#
5
6# Set to a list of packages to install.
7export VM_EXTRA_PACKAGES="firstboot-freebsd-update firstboot-pkgs \
8	google-cloud-sdk panicmail sudo firstboot-growfs \
9	sysutils/py-google-compute-engine"
10
11# Set to a list of third-party software to enable in rc.conf(5).
12export VM_RC_LIST="google_accounts_manager ntpd sshd firstboot_growfs \
13	firstboot_pkgs firstboot_freebsd_update google_startup \
14	google_accounts_daemon google_clock_skew_daemon
15	google_instance_setup google_ip_forwarding_daemon
16	google_network_setup"
17
18vm_extra_install_base() {
19	echo 'search google.internal' > ${DESTDIR}/etc/resolv.conf
20	echo 'nameserver 169.254.169.254' >> ${DESTDIR}/etc/resolv.conf
21	echo 'nameserver 8.8.8.8' >> ${DESTDIR}/etc/resolv.conf
22}
23
24vm_extra_pre_umount() {
25	cat << EOF >> ${DESTDIR}/etc/rc.conf
26dumpdev="AUTO"
27ifconfig_DEFAULT="SYNCDHCP mtu 1460"
28ntpd_sync_on_start="YES"
29# need to fill in something here
30#firstboot_pkgs_list=""
31panicmail_autosubmit="YES"
32EOF
33
34	cat << EOF >> ${DESTDIR}/boot/loader.conf
35autoboot_delay="-1"
36beastie_disable="YES"
37loader_logo="none"
38hw.memtest.tests="0"
39console="comconsole,vidconsole"
40hw.vtnet.mq_disable=1
41kern.timecounter.hardware=ACPI-safe
42aesni_load="YES"
43nvme_load="YES"
44EOF
45
46	echo '169.254.169.254 metadata.google.internal metadata' > \
47		${DESTDIR}/etc/hosts
48
49        # overwrite ntp.conf
50	cat << EOF > ${DESTDIR}/etc/ntp.conf
51server metadata.google.internal iburst
52
53restrict default kod nomodify notrap nopeer noquery
54restrict -6 default kod nomodify notrap nopeer noquery
55
56restrict 127.0.0.1
57restrict -6 ::1
58restrict 127.127.1.0
59EOF
60
61	cat << EOF >> ${DESTDIR}/etc/syslog.conf
62*.err;kern.warning;auth.notice;mail.crit                /dev/console
63EOF
64
65	cat << EOF >> ${DESTDIR}/etc/ssh/sshd_config
66ChallengeResponseAuthentication no
67X11Forwarding no
68AcceptEnv LANG
69Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc
70AllowAgentForwarding no
71ClientAliveInterval 420
72EOF
73
74	cat << EOF >> ${DESTDIR}/etc/crontab
750       3       *       *       *       root    /usr/sbin/freebsd-update cron
76EOF
77
78	cat << EOF >> ${DESTDIR}/etc/sysctl.conf
79net.inet.icmp.drop_redirect=1
80net.inet.ip.redirect=0
81net.inet.tcp.blackhole=2
82net.inet.udp.blackhole=1
83kern.ipc.somaxconn=1024
84debug.trace_on_panic=1
85debug.debugger_on_panic=0
86EOF
87
88	## XXX: Verify this is needed.  I do not see this requirement
89	## in the docs, and it impairs the ability to boot-test a copy
90	## of the image prior to packaging for upload to GCE.
91	#sed -E -i '' 's/^([^#].*[[:space:]])on/\1off/' ${DESTDIR}/etc/ttys
92
93	touch ${DESTDIR}/firstboot
94
95	rm -f ${DESTDIR}/etc/resolv.conf
96
97	return 0
98}
99