1
0
mirror of https://gitlab.alpinelinux.org/alpine/cloud/tiny-cloud.git synced 2025-12-16 03:42:44 +03:00
tiny-cloud/etc/init.d/tiny-cloud-early
Jake Buchholz Göktürk 07f0e646e8 Introducing Tiny Cloud
2022-01-02 10:15:20 -08:00

36 lines
966 B
Bash

#!/sbin/openrc-run
# vim:set ft=sh noet ts=4:
description="Tiny Cloud Bootstrap - early phase"
depend() {
before mdev
}
_expand_root_partition() {
local mountpoint=$(busybox mountpoint -n / | cut -d' ' -f1)
local volume=$(echo "$mountpoint" |
sed -Ee "s/(nvme\d+n\d|(xv|s)d[a-z])p?\d?$/\1/"
)
if [ "$mountpoint" != "$volume" ]; then
partition=$(echo "$volume" | sed -Ee "s/.*(\d+)$/\2/")
einfo "Expanding root partition to volume size..."
echo ", +" | sfdisk -q --no-reread -N "$partition" "$volume"
einfo "Updating kernel with new partition table..."
partx -u "$volume"
fi
einfo "Resizing root filesystem..."
resize2fs "$mountpoint"
}
start() {
[ -f "/var/lib/cloud/.bootstrap-complete" ] && return 0
[ -d "/var/lib/cloud" ] || mkdir -p /var/lib/cloud
source /etc/conf.d/tiny-cloud # or use auto-sourced tiny-cloud-early?
ebegin "Expanding Root Partition"; _expand_root_partition; eend $?
# TODO: _setup mdev things, if applicable
}