]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - release/tools/gce.conf
amd64: use register macros for gdb_cpu_getreg()
[FreeBSD/FreeBSD.git] / release / tools / gce.conf
1 #!/bin/sh
2 #
3 # $FreeBSD$
4 #
5
6 # The default of 3GB is too small for GCE, so override the size here.
7 export VMSIZE=20G
8
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"
13
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"
19
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
24 }
25
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
30
31         cat << EOF >> ${DESTDIR}/etc/rc.conf
32 dumpdev="AUTO"
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"
38 EOF
39
40         cat << EOF >> ${DESTDIR}/boot/loader.conf
41 autoboot_delay="-1"
42 beastie_disable="YES"
43 loader_logo="none"
44 hw.memtest.tests="0"
45 console="comconsole,vidconsole"
46 hw.vtnet.mq_disable=1
47 kern.timecounter.hardware=ACPI-safe
48 aesni_load="YES"
49 nvme_load="YES"
50 EOF
51
52         echo '169.254.169.254 metadata.google.internal metadata' >> \
53                 ${DESTDIR}/etc/hosts
54
55         # overwrite ntp.conf
56         cat << EOF > ${DESTDIR}/etc/ntp.conf
57 server metadata.google.internal iburst
58
59 restrict default kod nomodify notrap nopeer noquery
60 restrict -6 default kod nomodify notrap nopeer noquery
61
62 restrict 127.0.0.1
63 restrict -6 ::1
64 restrict 127.127.1.0
65 EOF
66
67         cat << EOF >> ${DESTDIR}/etc/syslog.conf
68 *.err;kern.warning;auth.notice;mail.crit                /dev/console
69 EOF
70
71         cat << EOF >> ${DESTDIR}/etc/ssh/sshd_config
72 ChallengeResponseAuthentication no
73 X11Forwarding no
74 AcceptEnv LANG
75 AllowAgentForwarding no
76 ClientAliveInterval 420
77 EOF
78
79         cat << EOF >> ${DESTDIR}/etc/crontab
80 0       3       *       *       *       root    /usr/sbin/freebsd-update cron
81 EOF
82
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
91 EOF
92
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
96         # the image.
97         if [ ! -c "${DESTDIR}/dev/null" ]; then
98                 mkdir -p ${DESTDIR}/dev
99                 mount -t devfs devfs ${DESTDIR}/dev
100         fi
101         if [ -e "${DESTDIR}/../ftp/src.txz" ]; then
102                 tar fxJ ${DESTDIR}/../ftp/src.txz -C ${DESTDIR}
103         fi
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
108                         chroot ${DESTDIR} \
109                                 make -C /usr/ports/${PACKAGE} fetch
110                 done
111         fi
112         if [ -c "${DESTDIR}/dev/null" ]; then
113                 umount_loop ${DESTDIR}/dev
114         fi
115
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
120
121         touch ${DESTDIR}/firstboot
122
123         rm -f ${DESTDIR}/etc/resolv.conf
124
125         return 0
126 }