alpine-zdt-images/alpine-cloud-images/scripts/setup-cloudinit
Stefan Reimer 9ccfc0cdaa Add 'alpine-cloud-images/' from commit '99474a8a6ab7a22e90f5f73d7cfb706cab51ace0'
git-subtree-dir: alpine-cloud-images
git-subtree-mainline: 043116c92a
git-subtree-split: 99474a8a6a
2022-03-11 18:31:44 +01:00

36 lines
1001 B
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"
;;
*)
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