2023-04-28 10:12:12 +00:00
|
|
|
#!/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
|
|
|
|
}
|
|
|
|
|
2023-11-14 16:52:02 +00:00
|
|
|
greater_or_equal() {
|
|
|
|
return $(echo "$1 $2" | awk '{print ($1 < $2)}')
|
|
|
|
}
|
|
|
|
|
2023-04-28 10:12:12 +00:00
|
|
|
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..."
|
2023-06-21 14:25:52 +00:00
|
|
|
|
|
|
|
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
|
2023-11-14 16:52:02 +00:00
|
|
|
chroot "$TARGET" /sbin/tiny-cloud --enable
|
|
|
|
elif greater_or_equal "$VERSION" 3.18; then
|
2023-06-21 14:25:52 +00:00
|
|
|
# 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
|
2023-04-28 10:12:12 +00:00
|
|
|
fi
|