1
0
mirror of https://gitlab.alpinelinux.org/alpine/cloud/tiny-cloud.git synced 2025-12-14 19:02:45 +03:00

properly detect empty userdata

This commit is contained in:
Jake Buchholz Göktürk 2025-11-30 19:56:46 +00:00
parent 3e886c87fb
commit 3e44e41603
5 changed files with 25 additions and 0 deletions

View File

@ -1,5 +1,9 @@
# CHANGELOG # CHANGELOG
## YYYY-MM-DD - Tiny Cloud vX.Y.Z
* Correctly identify empty `user-data` content instead of flagging it as "unknown".
## 2025-06-11 - Tiny Cloud v3.2.2 ## 2025-06-11 - Tiny Cloud v3.2.2
* Fix `Makefile` to dynamically generate the list of clouds, allowing the new * Fix `Makefile` to dynamically generate the list of clouds, allowing the new

View File

@ -18,6 +18,10 @@
* Support additional features of `#cloud-config` as needed * Support additional features of `#cloud-config` as needed
* Support for multipart `user-data` payload?
* Support for `#network-config`?
* Support LVM partitioning and non-`ext[234]` filesystems? * Support LVM partitioning and non-`ext[234]` filesystems?
* Support other cloud providers... * Support other cloud providers...

View File

@ -294,6 +294,9 @@ userdata_type() {
if [ ! -f "$TINY_CLOUD_VAR/user-data" ]; then if [ ! -f "$TINY_CLOUD_VAR/user-data" ]; then
echo missing echo missing
return return
elif [ ! -s "$TINY_CLOUD_VAR/user-data" ]; then
echo empty
return
fi fi
header=$(head -n1 "$TINY_CLOUD_VAR/user-data" | sed -e 's/[[:space:]].*//g') header=$(head -n1 "$TINY_CLOUD_VAR/user-data" | sed -e 's/[[:space:]].*//g')
case "$header" in case "$header" in

View File

@ -0,0 +1,9 @@
# Empty UserData Functions
# vim:set filetype=sh:
# shellcheck shell=sh
init__empty_userdata() {
log -i -t "$phase" notice "$ACTION: empty user-data found"
}
INIT_ACTIONS_MAIN="empty_userdata ${INIT_ACTIONS_MAIN}"

View File

@ -197,6 +197,11 @@ userdata_type_body() {
-o match:"missing" \ -o match:"missing" \
sh -c ". \"$lib\"; userdata_type" sh -c ". \"$lib\"; userdata_type"
touch var/lib/cloud/user-data
CLOUD="$c" atf_check \
-o match:"empty" \
sh -c ". \"$lib\"; userdata_type"
echo "#tiny-cloud-config" > var/lib/cloud/user-data echo "#tiny-cloud-config" > var/lib/cloud/user-data
CLOUD="$c" atf_check \ CLOUD="$c" atf_check \
-o match:"tiny-cloud-config" \ -o match:"tiny-cloud-config" \