1#!/bin/sh 2 3. ${WORLDDIR}/release/tools/ec2.conf 4 5# Packages to install into the image we're creating. In addition to packages 6# present on all EC2 AMIs, we install: 7# * ec2-scripts, which provides a range of EC2ification startup scripts, 8# * firstboot-freebsd-update, to install security updates at first boot, 9# * firstboot-pkgs, to install packages at first boot, and 10# * isc-dhcp44-client, used for IPv6 network setup. 11export VM_EXTRA_PACKAGES="${VM_EXTRA_PACKAGES} ec2-scripts \ 12 firstboot-freebsd-update firstboot-pkgs isc-dhcp44-client" 13 14# Services to enable in rc.conf(5). 15export VM_RC_LIST="${VM_RC_LIST} ec2_configinit ec2_ephemeral_swap \ 16 ec2_fetchkey ec2_loghostkey firstboot_freebsd_update firstboot_pkgs \ 17 growfs sshd" 18 19vm_extra_pre_umount() { 20 # The AWS CLI tools are generally useful, and small enough that they 21 # will download quickly; but users will often override this setting 22 # via EC2 user-data. 23 echo 'firstboot_pkgs_list="devel/py-awscli"' >> ${DESTDIR}/etc/rc.conf 24 25 # EC2 instances use DHCP to get their network configuration. IPv6 26 # requires accept_rtadv. 27 echo 'ifconfig_DEFAULT="SYNCDHCP accept_rtadv"' >> ${DESTDIR}/etc/rc.conf 28 29 # The EC2 DHCP server can be trusted to know whether an IP address is 30 # assigned to us; we don't need to ARP to check if anyone else is using 31 # the address before we start using it. 32 echo 'dhclient_arpwait="NO"' >> ${DESTDIR}/etc/rc.conf 33 34 # Enable IPv6 on all interfaces, and spawn DHCPv6 via rtsold 35 echo 'ipv6_activate_all_interfaces="YES"' >> ${DESTDIR}/etc/rc.conf 36 echo 'rtsold_enable="YES"' >> ${DESTDIR}/etc/rc.conf 37 echo 'rtsold_flags="-M /usr/local/libexec/rtsold-M -a"' >> ${DESTDIR}/etc/rc.conf 38 39 # Provide a script which rtsold can use to launch DHCPv6 40 mkdir -p ${DESTDIR}/usr/local/libexec 41 cat > ${DESTDIR}/usr/local/libexec/rtsold-M <<'EOF' 42#!/bin/sh 43 44/usr/local/sbin/dhclient -6 -nw -N -cf /dev/null $1 45EOF 46 chmod 755 ${DESTDIR}/usr/local/libexec/rtsold-M 47 48 # Any EC2 ephemeral disks seen when the system first boots will 49 # be "new" disks; there is no "previous boot" when they might have 50 # been seen and used already. 51 touch ${DESTDIR}/var/db/ec2_ephemeral_diskseen 52 53 # Configuration common to all EC2 AMIs 54 ec2_common 55 56 return 0 57} 58