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