Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Jan 2018 21:17:48 +0000
From:      Rafal Lukawiecki <raf@rafal.net>
To:        Colin Percival <cperciva@tarsnap.com>
Cc:        freebsd-cloud@freebsd.org, Julian Elischer <julian@freebsd.org>
Subject:   Re: AMI building AMI
Message-ID:  <DE34F1A6-C9CB-451F-BA10-DB8C7CDB2B3A@rafal.net>
In-Reply-To: <DFCBCB78-A543-4C4B-BF03-ED0FDFAB1125@rafal.net>
References:  <085D225B-2E99-4540-B693-223087B14A27@rafal.net> <0100016099578ea7-02da1d5c-997d-47be-9cd8-dc6b75bbeda6-000000@email.amazonses.com> <8BCB67B8-DE56-491A-8E6A-95AFB83F71D6@rafal.net> <0100016099671dff-32d986bf-3979-40a3-accf-4d17c2020403-000000@email.amazonses.com> <8538BFB9-B82C-4520-ADB3-E25040EA1B30@rafal.net> <01000160a0283ad5-12b330d3-3f4b-43ea-9cdc-2524f5f42f4a-000000@email.amazonses.com> <DC1A9FE3-DF1F-4A87-8539-888D09CBA3EA@rafal.net> <004116c5-0938-5570-f119-fdc21e91b2ad@freebsd.org> <559A9E86-6E97-4A8D-96CC-95FC9180A483@rafal.net> <50f75b01-2ea3-f7fd-24a6-65a4d64ae16d@freebsd.org> <77A688A9-6272-4FC6-89DF-4F9231B7B3CE@rafal.net> <DFCBCB78-A543-4C4B-BF03-ED0FDFAB1125@rafal.net>

next in thread | previous in thread | raw e-mail | index | archive | help
Colin, Everyone,

Here is the final script that has managed to run, unattended! On a =
c4.x4large it completes the task in 11 minutes, which is impressive, =
considering the long list of packages (126). Following that, I am able =
to encrypt the AMI while copying it across regions using:

aws ec2 copy-image --source-region us-east-1 --region eu-west-1 =
--source-image-id ami-x --encrypted --name =E2=80=9CMy FreeBSD"

If you would like to update your blog post with this, now fully tested =
script, perhaps others would benefit. Please note credit is due to =
Julian, who got me unstuck regarding pkg -c and resolv.conf, many =
thanks, Julian.

#!/bin/sh
set -x
export ASSUME_ALWAYS_YES=3DYES
PKGS_TO_INSTALL=3D=E2=80=9Clist of packages to install"
pkg -r /mnt fetch -d $PKGS_TO_INSTALL
pkg -r /mnt update -f
mv /mnt/etc/resolv.conf /mnt/etc/resolv.conf.orig
cp /etc/resolv.conf /mnt/etc/resolv.conf
yes n | pkg -c /mnt -o ASSUME_ALWAYS_YES=3DYES install $PKGS_TO_INSTALL
mv /mnt/etc/resolv.conf.orig /mnt/etc/resolv.conf
svnlite --non-interactive --trust-server-cert-failures=3Dunknown-ca co =
https://svn.freebsd.org/base/releng/11.1/ /usr/src/
cd /usr/src
cat > /tmp/kernel.patch <<EOT
*** patches to apply ***
EOT
patch < /tmp/kernel.patch
make DESTDIR=3D/mnt kernel -j16
mkami "FreeBSD 11.1 Custom AMI=E2=80=9D =E2=80=9CMy custom AMI =
description"
shutdown -p now

Rafal
--
Rafal Lukawiecki
Data Scientist=20
Project Botticelli Ltd

> On 2 Jan 2018, at 20:48, Rafal Lukawiecki <raf@rafal.net> wrote:
>=20
> I have encountered another, hopefully minor issue running pkg in the =
unattended script. When it installs a package (postfix-sasl) it expects =
keyboard input to =E2=80=9CWould you like to active Postfix in =
/usr/local/etc/mail/mailer.conf [n]?=E2=80=9D. I have tried both:
>=20
> export ASSUME_ALWAYS_YES=3DYES
> pkg -c /mnt -o ASSUME_ALWAYS_YES=3DYES install $PKGS_TO_INSTALL
>=20
> but the process still hangs waiting for input. Are there any other =
flags or tricks I could pass to pkg, short of prefixing it with =E2=80=9Cy=
es n |=E2=80=9D? Looking through man for pkg I do not see any options =
designed for such unattended install cases.
>=20
> Many thanks for your help.
>=20
> Rafal
>=20
> _______________________________________________
> freebsd-cloud@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-cloud
> To unsubscribe, send any mail to =
"freebsd-cloud-unsubscribe@freebsd.org"




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?DE34F1A6-C9CB-451F-BA10-DB8C7CDB2B3A>