]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - release/tools/gce.conf
Merge libc++ trunk r338150, and resolve conflicts.
[FreeBSD/FreeBSD.git] / release / tools / gce.conf
1 #!/bin/sh
2 #
3 # $FreeBSD$
4 #
5
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 firstboot-growfs \
9         sysutils/py-google-compute-engine"
10
11 # Set to a list of third-party software to enable in rc.conf(5).
12 export VM_RC_LIST="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
18 vm_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
24 vm_extra_pre_umount() {
25         cat << EOF >> ${DESTDIR}/etc/rc.conf
26 dumpdev="AUTO"
27 ifconfig_DEFAULT="SYNCDHCP mtu 1460"
28 ntpd_sync_on_start="YES"
29 # need to fill in something here
30 #firstboot_pkgs_list=""
31 panicmail_autosubmit="YES"
32 EOF
33
34         cat << EOF >> ${DESTDIR}/boot/loader.conf
35 autoboot_delay="-1"
36 beastie_disable="YES"
37 loader_logo="none"
38 hw.memtest.tests="0"
39 console="comconsole,vidconsole"
40 hw.vtnet.mq_disable=1
41 kern.timecounter.hardware=ACPI-safe
42 aesni_load="YES"
43 nvme_load="YES"
44 EOF
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
51 server metadata.google.internal iburst
52
53 restrict default kod nomodify notrap nopeer noquery
54 restrict -6 default kod nomodify notrap nopeer noquery
55
56 restrict 127.0.0.1
57 restrict -6 ::1
58 restrict 127.127.1.0
59 EOF
60
61         cat << EOF >> ${DESTDIR}/etc/syslog.conf
62 *.err;kern.warning;auth.notice;mail.crit                /dev/console
63 EOF
64
65         cat << EOF >> ${DESTDIR}/etc/ssh/sshd_config
66 ChallengeResponseAuthentication no
67 X11Forwarding no
68 AcceptEnv LANG
69 AllowAgentForwarding no
70 ClientAliveInterval 420
71 EOF
72
73         cat << EOF >> ${DESTDIR}/etc/crontab
74 0       3       *       *       *       root    /usr/sbin/freebsd-update cron
75 EOF
76
77         cat << EOF >> ${DESTDIR}/etc/sysctl.conf
78 net.inet.icmp.drop_redirect=1
79 net.inet.ip.redirect=0
80 net.inet.tcp.blackhole=2
81 net.inet.udp.blackhole=1
82 kern.ipc.somaxconn=1024
83 debug.trace_on_panic=1
84 debug.debugger_on_panic=0
85 EOF
86
87         # To meet GCE marketplace requirements, extract the src.txz and
88         # ports.txz distributions to the target virtual machine disk image
89         # and fetch the sources for the third-party software installed on
90         # the image.
91         if [ ! -c "${DESTDIR}/dev/null" ]; then
92                 mkdir -p ${DESTDIR}/dev
93                 mount -t devfs devfs ${DESTDIR}/dev
94         fi
95         if [ -e "${DESTDIR}/../ftp/src.txz" ]; then
96                 tar fxJ ${DESTDIR}/../ftp/src.txz -C ${DESTDIR}
97         fi
98         if [ -e "${DESTDIR}/../ftp/ports.txz" ]; then
99                 tar fxJ ${DESTDIR}/../ftp/ports.txz -C ${DESTDIR}
100                 _INSTALLED_PACKAGES=$(chroot ${DESTDIR} pkg info -o -q -a)
101                 for PACKAGE in ${_INSTALLED_PACKAGES}; do
102                         chroot ${DESTDIR} \
103                                 make -C /usr/ports/${PACKAGE} fetch
104                 done
105         fi
106         if [ -c "${DESTDIR}/dev/null" ]; then
107                 umount_loop ${DESTDIR}/dev
108         fi
109
110         ## XXX: Verify this is needed.  I do not see this requirement
111         ## in the docs, and it impairs the ability to boot-test a copy
112         ## of the image prior to packaging for upload to GCE.
113         #sed -E -i '' 's/^([^#].*[[:space:]])on/\1off/' ${DESTDIR}/etc/ttys
114
115         touch ${DESTDIR}/firstboot
116
117         rm -f ${DESTDIR}/etc/resolv.conf
118
119         return 0
120 }