mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-31 04:23:40 +00:00
@@ -317,18 +317,31 @@ elif [ "${IMAGE_TYPE}" = img ]; then
|
|||||||
|
|
||||||
TMPDIR=$(mktemp -d)
|
TMPDIR=$(mktemp -d)
|
||||||
|
|
||||||
mount `partition_for ${OUTPUT_DEVICE} 2` $TMPDIR
|
mkdir -p $TMPDIR/boot $TMPDIR/root
|
||||||
mkdir $TMPDIR/boot
|
mount `partition_for ${OUTPUT_DEVICE} 2` $TMPDIR/root
|
||||||
mount `partition_for ${OUTPUT_DEVICE} 1` $TMPDIR/boot
|
mount `partition_for ${OUTPUT_DEVICE} 1` $TMPDIR/boot
|
||||||
unsquashfs -f -d $TMPDIR $prep_results_dir/binary/live/filesystem.squashfs
|
unsquashfs -n -f -d $TMPDIR $prep_results_dir/binary/live/filesystem.squashfs boot
|
||||||
|
|
||||||
|
mkdir $TMPDIR/root/images $TMPDIR/root/config
|
||||||
|
B3SUM=$(b3sum $prep_results_dir/binary/live/filesystem.squashfs | head -c 16)
|
||||||
|
cp $prep_results_dir/binary/live/filesystem.squashfs $TMPDIR/root/images/$B3SUM.rootfs
|
||||||
|
ln -rsf $TMPDIR/root/images/$B3SUM.rootfs $TMPDIR/root/config/current.rootfs
|
||||||
|
|
||||||
|
mkdir -p $TMPDIR/next $TMPDIR/lower $TMPDIR/root/config/work $TMPDIR/root/config/overlay
|
||||||
|
mount $TMPDIR/root/config/current.rootfs $TMPDIR/lower
|
||||||
|
|
||||||
|
mount -t overlay -o lowerdir=$TMPDIR/lower,workdir=$TMPDIR/root/config/work,upperdir=$TMPDIR/root/config/overlay overlay $TMPDIR/next
|
||||||
|
|
||||||
if [ "${IB_TARGET_PLATFORM}" = "raspberrypi" ]; then
|
if [ "${IB_TARGET_PLATFORM}" = "raspberrypi" ]; then
|
||||||
sed -i 's| boot=startos| init=/usr/lib/startos/scripts/init_resize\.sh|' $TMPDIR/boot/cmdline.txt
|
sed -i 's| boot=startos| boot=startos init=/usr/lib/startos/scripts/init_resize\.sh|' $TMPDIR/boot/cmdline.txt
|
||||||
rsync -a $base_dir/raspberrypi/img/ $TMPDIR/
|
rsync -a $base_dir/raspberrypi/img/ $TMPDIR/next/
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
umount $TMPDIR/next
|
||||||
|
umount $TMPDIR/lower
|
||||||
|
|
||||||
umount $TMPDIR/boot
|
umount $TMPDIR/boot
|
||||||
umount $TMPDIR
|
umount $TMPDIR/root
|
||||||
|
|
||||||
e2fsck -fy `partition_for ${OUTPUT_DEVICE} 2`
|
e2fsck -fy `partition_for ${OUTPUT_DEVICE} 2`
|
||||||
resize2fs -M `partition_for ${OUTPUT_DEVICE} 2`
|
resize2fs -M `partition_for ${OUTPUT_DEVICE} 2`
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ apt-get install -yq \
|
|||||||
dosfstools \
|
dosfstools \
|
||||||
e2fsprogs \
|
e2fsprogs \
|
||||||
squashfs-tools \
|
squashfs-tools \
|
||||||
rsync
|
rsync \
|
||||||
|
b3sum
|
||||||
# TODO: remove when util-linux is released at v2.39.3
|
# TODO: remove when util-linux is released at v2.39.3
|
||||||
apt-get install -yq \
|
apt-get install -yq \
|
||||||
git \
|
git \
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
get_variables () {
|
get_variables () {
|
||||||
ROOT_PART_DEV=$(findmnt / -o source -n)
|
ROOT_PART_DEV=$(findmnt /media/startos/root -o source -n)
|
||||||
ROOT_PART_NAME=$(echo "$ROOT_PART_DEV" | cut -d "/" -f 3)
|
ROOT_PART_NAME=$(echo "$ROOT_PART_DEV" | cut -d "/" -f 3)
|
||||||
ROOT_DEV_NAME=$(echo /sys/block/*/"${ROOT_PART_NAME}" | cut -d "/" -f 4)
|
ROOT_DEV_NAME=$(echo /sys/block/*/"${ROOT_PART_NAME}" | cut -d "/" -f 4)
|
||||||
ROOT_DEV="/dev/${ROOT_DEV_NAME}"
|
ROOT_DEV="/dev/${ROOT_DEV_NAME}"
|
||||||
@@ -89,12 +89,12 @@ main () {
|
|||||||
|
|
||||||
resize2fs $ROOT_PART_DEV
|
resize2fs $ROOT_PART_DEV
|
||||||
|
|
||||||
if ! systemd-machine-id-setup; then
|
if ! systemd-machine-id-setup --root=/media/startos/config/overlay/; then
|
||||||
FAIL_REASON="systemd-machine-id-setup failed"
|
FAIL_REASON="systemd-machine-id-setup failed"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! ssh-keygen -A; then
|
if ! mkdir -p /media/startos/config/overlay/etc/ssh && ssh-keygen -A -f /media/startos/config/overlay/; then
|
||||||
FAIL_REASON="ssh host key generation failed"
|
FAIL_REASON="ssh host key generation failed"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@@ -104,9 +104,6 @@ main () {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
mount -t proc proc /proc
|
|
||||||
mount -t sysfs sys /sys
|
|
||||||
mount -t tmpfs tmp /run
|
|
||||||
mkdir -p /run/systemd
|
mkdir -p /run/systemd
|
||||||
mount /boot
|
mount /boot
|
||||||
mount / -o remount,ro
|
mount / -o remount,ro
|
||||||
@@ -114,7 +111,7 @@ mount / -o remount,ro
|
|||||||
beep
|
beep
|
||||||
|
|
||||||
if main; then
|
if main; then
|
||||||
sed -i 's| init=/usr/lib/startos/scripts/init_resize\.sh| boot=startos|' /boot/cmdline.txt
|
sed -i 's| init=/usr/lib/startos/scripts/init_resize\.sh||' /boot/cmdline.txt
|
||||||
echo "Resized root filesystem. Rebooting in 5 seconds..."
|
echo "Resized root filesystem. Rebooting in 5 seconds..."
|
||||||
sleep 5
|
sleep 5
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user