1*a9710349SColin Percival#!/bin/sh 2*a9710349SColin Percival 3*a9710349SColin Percival. ${WORLDDIR}/release/tools/ec2.conf 4*a9710349SColin Percival 5*a9710349SColin Percival# Build with a (just under) 20 GB partition; all of the "desktop" bits 6*a9710349SColin Percival# significantly bloat the image compared with stock FreeBSD. 7*a9710349SColin Percivalexport VMSIZE=20000m 8*a9710349SColin Percival 9*a9710349SColin Percival# Packages to install into the image we're creating. In addition to packages 10*a9710349SColin Percival# present on all EC2 AMIs, we install: 11*a9710349SColin Percival# * amazon-ssm-agent (not enabled by default, but some users need to use 12*a9710349SColin Percival# it on systems not connected to the internet), 13*a9710349SColin Percival# * ec2-scripts, which provides a range of EC2ification startup scripts, 14*a9710349SColin Percival# * firstboot-pkg-upgrade, to install security updates at first boot, 15*a9710349SColin Percival# * firstboot-pkgs, to install packages at first boot, and 16*a9710349SColin Percival# * isc-dhcp44-client, used for IPv6 network setup, and 17*a9710349SColin Percival# * kde, to provide a useful desktop environment 18*a9710349SColin Percival# * chromium and libreoffice, to provide an office environment, 19*a9710349SColin Percival# * xorg, xrdp, and xorgxrdp, to provide the display server. 20*a9710349SColin Percivalexport VM_EXTRA_PACKAGES="${VM_EXTRA_PACKAGES} amazon-ssm-agent ec2-scripts \ 21*a9710349SColin Percival firstboot-pkg-upgrade firstboot-pkgs isc-dhcp44-client \ 22*a9710349SColin Percival kde chromium libreoffice xorg xrdp xorgxrdp" 23*a9710349SColin Percival 24*a9710349SColin Percival# Services to enable in rc.conf(5). 25*a9710349SColin Percivalexport VM_RC_LIST="${VM_RC_LIST} ec2_configinit ec2_ephemeral_swap \ 26*a9710349SColin Percival ec2_fetchkey ec2_setpass ec2_loghostkey firstboot_pkg_upgrade \ 27*a9710349SColin Percival firstboot_pkgs growfs growfs_postboot sshd dbus xrdp xrdp_sesman" 28*a9710349SColin Percival 29*a9710349SColin Percivalvm_extra_pre_umount() { 30*a9710349SColin Percival # Limit firstboot_pkg_upgrade to the base system. 31*a9710349SColin Percival echo 'firstboot_pkg_upgrade_repos="FreeBSD-base"' >> ${DESTDIR}/etc/rc.conf 32*a9710349SColin Percival 33*a9710349SColin Percival # Don't allocate swap space when we first boot; that makes it 34*a9710349SColin Percival # impossible to grow the root filesystem later. 35*a9710349SColin Percival echo 'growfs_swap_size=0' >> ${DESTDIR}/etc/rc.conf 36*a9710349SColin Percival 37*a9710349SColin Percival # Give users a KDE desktop by default. 38*a9710349SColin Percival sed -i '' -e '/exec.*startplasma/s/^# //' ${DESTDIR}/usr/local/etc/xrdp/startwm.sh 39*a9710349SColin Percival 40*a9710349SColin Percival # Use UID/GID _xrdp. Disabled for now until the port supports this. 41*a9710349SColin Percival #sed -i '' -e '/SessionSockdirGroup/s/^#//' ${DESTDIR}/usr/local/etc/xrdp/sesman.ini 42*a9710349SColin Percival #sed -i '' -E -e '/runtime_(user|group)=_xrdp/s/^#//' ${DESTDIR}/usr/local/etc/xrdp/xrdp.ini 43*a9710349SColin Percival 44*a9710349SColin Percival # Set login password and print in encrypted form to the console. 45*a9710349SColin Percival # This will be removed from here once it lands in the ec2-scripts port. 46*a9710349SColin Percival install -m 755 ${WORLDDIR}/release/tools/ec2_setpass ${DESTDIR}/usr/local/etc/rc.d 47*a9710349SColin Percival metalog_add_data ./usr/local/etc/rc.d/ec2_setpass 0755 48*a9710349SColin Percival 49*a9710349SColin Percival # Run some additional commands on first boot which won't be 50*a9710349SColin Percival # necessary once (a) the xrdp port gains host key generation as 51*a9710349SColin Percival # an rc.d script, and (b) pkg triggers are logged in METALOG and 52*a9710349SColin Percival # run from a firstboot script. 53*a9710349SColin Percival install -m 755 ${WORLDDIR}/release/tools/ec2_desktop_extras ${DESTDIR}/usr/local/etc/rc.d 54*a9710349SColin Percival metalog_add_data ./usr/local/etc/rc.d/ec2_desktop_extras 0755 55*a9710349SColin Percival 56*a9710349SColin Percival # Any EC2 ephemeral disks seen when the system first boots will 57*a9710349SColin Percival # be "new" disks; there is no "previous boot" when they might have 58*a9710349SColin Percival # been seen and used already. 59*a9710349SColin Percival touch ${DESTDIR}/var/db/ec2_ephemeral_diskseen 60*a9710349SColin Percival metalog_add_data ./var/db/ec2_ephemeral_diskseen 61*a9710349SColin Percival 62*a9710349SColin Percival # Configuration common to all EC2 AMIs 63*a9710349SColin Percival ec2_common 64*a9710349SColin Percival 65*a9710349SColin Percival # Standard FreeBSD network configuration 66*a9710349SColin Percival ec2_base_networking 67*a9710349SColin Percival 68*a9710349SColin Percival # Add files from packages which weren't recorded in metalog 69*a9710349SColin Percival metalog_add_data ./usr/local/etc/dhclient.conf 70*a9710349SColin Percival metalog_add_data ./usr/local/etc/ssl/cert.pem 71*a9710349SColin Percival 72*a9710349SColin Percival return 0 73*a9710349SColin Percival} 74