alpine-zdt-images/alpine-cloud-images/scripts/setup-tiny

46 lines
1.6 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
}
if [ "$VERSION" = "3.12" ]; then
# tiny-cloud-network requires ifupdown-ng, not in 3.12
einfo "Configuring Tiny EC2 Bootstrap..."
echo "EC2_USER=$IMAGE_LOGIN" > /etc/conf.d/tiny-ec2-bootstrap
else
einfo "Configuring Tiny Cloud..."
TC_CONF="$TARGET/etc/tiny-cloud.conf"
# tiny-cloud >= 3.0.0 moved configs, the following supports older versions
[ ! -f "$TC_CONF" ] && TC_CONF="$TARGET/etc/conf.d/tiny-cloud"
sed -i.bak -Ee "s/^#?CLOUD_USER=.*/CLOUD_USER=$IMAGE_LOGIN/" "$TC_CONF"
rm "$TC_CONF.bak"
# tiny-cloud >= 3.0.0 sets up init scripts with /sbin/tiny-cloud --setup
if [ -f "$TARGET/sbin/tiny-cloud" ]; then
# fixed in tiny-cloud >3.0.1
#chroot "$TARGET" /sbin/tiny-cloud --enable
# logic directly implemented here, for now
echo -- "- removing tiny-cloud* from all runlevels"
rm -f "$TARGET"/etc/runlevels/*/tiny-cloud*
ln -s /etc/init.d/tiny-cloud-boot "$TARGET"/etc/runlevels/boot
echo -- "+ tiny-cloud-boot service added to boot runlevel"
for p in early main final; do
ln -s "/etc/init.d/tiny-cloud-$p" "$TARGET"/etc/runlevels/default
echo -- "+ tiny-cloud-$p service added to default runlevel"
done
# TODO: will need to update this for >3.18
elif [ "$VERSION" = "3.18" ]; then
# 3.18 has tiny-cloud 3.0.0, and we didn't find what we expected
echo "Error: /sbin/tiny-cloud not found" >&2
exit 1
fi
fi