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 “My 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=YES
PKGS_TO_INSTALL=“list 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=YES install $PKGS_TO_INSTALL
mv /mnt/etc/resolv.conf.orig /mnt/etc/resolv.conf
svnlite --non-interactive --trust-server-cert-failures=unknown-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=/mnt kernel -j16
mkami "FreeBSD 11.1 Custom AMI” “My custom AMI description"
shutdown -p now

Rafal
--
Rafal Lukawiecki
Data Scientist 
Project Botticelli Ltd

> On 2 Jan 2018, at 20:48, Rafal Lukawiecki <r...@rafal.net> wrote:
> 
> 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 “Would you like to active Postfix in 
> /usr/local/etc/mail/mailer.conf [n]?”. I have tried both:
> 
> export ASSUME_ALWAYS_YES=YES
> pkg -c /mnt -o ASSUME_ALWAYS_YES=YES install $PKGS_TO_INSTALL
> 
> 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 “yes n |”? Looking 
> through man for pkg I do not see any options designed for such unattended 
> install cases.
> 
> Many thanks for your help.
> 
> Rafal
> 
> _______________________________________________
> freebsd-cloud@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-cloud
> To unsubscribe, send any mail to "freebsd-cloud-unsubscr...@freebsd.org"

_______________________________________________
freebsd-cloud@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-cloud
To unsubscribe, send any mail to "freebsd-cloud-unsubscr...@freebsd.org"

Reply via email to