49 lines
1.2 KiB
Bash
Executable File
49 lines
1.2 KiB
Bash
Executable File
#!/bin/sh -eu
|
|
# vim: ts=4 et:
|
|
|
|
[ -z "$DEBUG" ] || [ "$DEBUG" = 0 ] || set -x
|
|
|
|
TARGET=/mnt
|
|
|
|
einfo() {
|
|
printf '\n\033[1;7;36m> %s <\033[0m\n' "$@" >&2 # bold reversed cyan
|
|
}
|
|
|
|
einfo "Installing up cloud-init bootstrap components..."
|
|
|
|
# This adds the init scripts at the correct boot phases
|
|
chroot "$TARGET" /sbin/setup-cloud-init
|
|
|
|
# cloud-init locks our user by default which means alpine can't login from
|
|
# SSH. This seems like a bug in cloud-init that should be fixed but we can
|
|
# hack around it for now here.
|
|
if [ -f "$TARGET"/etc/cloud/cloud.cfg ]; then
|
|
sed -i '/lock_passwd:/s/True/False/' "$TARGET"/etc/cloud/cloud.cfg
|
|
fi
|
|
|
|
# configure the image for a particular cloud datasource
|
|
case "$CLOUD" in
|
|
aws)
|
|
DATASOURCE="Ec2"
|
|
;;
|
|
nocloud)
|
|
DATASOURCE="NoCloud"
|
|
;;
|
|
azure)
|
|
DATASOURCE="Azure"
|
|
;;
|
|
gcp)
|
|
DATASOURCE="GCE"
|
|
;;
|
|
oci)
|
|
DATASOURCE="Oracle"
|
|
;;
|
|
*)
|
|
echo "Unsupported Cloud '$CLOUD'" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
printf '\n\n# Cloud-Init will use default configuration for this DataSource\n'
|
|
printf 'datasource_list: ["%s"]\n' "$DATASOURCE" >> "$TARGET"/etc/cloud/cloud.cfg
|