diff --git a/confluent_osdeploy/el8-diskless/profiles/default/scripts/image2disk.py b/confluent_osdeploy/el8-diskless/profiles/default/scripts/image2disk.py index 85da6f1a..74b3a9ce 100644 --- a/confluent_osdeploy/el8-diskless/profiles/default/scripts/image2disk.py +++ b/confluent_osdeploy/el8-diskless/profiles/default/scripts/image2disk.py @@ -32,7 +32,9 @@ def get_next_part_meta(img, imgsize): def get_multipart_image_meta(img): img.seek(0, 2) imgsize = img.tell() - img.seek(31) + img.seek(16) + seekamt = img.read(1) + img.seek(struct.unpack('B', seekamt)[0], 1) partinfo = get_next_part_meta(img, imgsize) while partinfo: yield partinfo @@ -205,7 +207,7 @@ def install_to_disk(imgpath): swapsize = int(swapsize * 1024) deftotsize = swapsize mintotsize = swapsize - for fs in get_image_metadata('/run/imginst/sourceimage/rootimg.sfs'): + for fs in get_image_metadata(imgpath): allvols.append(fs) deftotsize += fs['initsize'] mintotsize += fs['minsize'] @@ -371,4 +373,4 @@ def install_to_disk(imgpath): if __name__ == '__main__': - install_to_disk('/run/imginst/sourceimage/rootimg.sfs') \ No newline at end of file + install_to_disk(os.environ['mountsrc']) \ No newline at end of file diff --git a/confluent_osdeploy/el8-diskless/profiles/default/scripts/imageboot.sh b/confluent_osdeploy/el8-diskless/profiles/default/scripts/imageboot.sh index b96dcd2a..b58b9f74 100644 --- a/confluent_osdeploy/el8-diskless/profiles/default/scripts/imageboot.sh +++ b/confluent_osdeploy/el8-diskless/profiles/default/scripts/imageboot.sh @@ -9,7 +9,7 @@ else fi /opt/confluent/bin/confluent_imginfo /mnt/remoteimg/rootimg.sfs > /tmp/rootimg.info loopdev=$(losetup -f) -mountsrc=$loopdev +export mountsrc=$loopdev losetup -r $loopdev /mnt/remoteimg/rootimg.sfs if grep '^Format: confluent_crypted' /tmp/rootimg.info > /dev/null; then curl -sf -H "CONFLUENT_NODENAME: $nodename" -H "CONFLUENT_APIKEY: $(cat /etc/confluent/confluent.apikey)" https://$confluent_mgr/confluent-api/self/profileprivate/pending/rootimg.key > /tmp/rootimg.key @@ -19,13 +19,12 @@ if grep '^Format: confluent_crypted' /tmp/rootimg.info > /dev/null; then len=$(((len-4096)/512)) dmsetup create cryptimg --table "0 $len crypt $cipher $key 0 $loopdev 8" /opt/confluent/bin/confluent_imginfo /dev/mapper/cryptimg > /tmp/rootimg.info - mntsrc=/dev/mapper/cryptimg + mountsrc=/dev/mapper/cryptimg fi if grep '^Format: squashfs' /tmp/rootimg.info > /dev/null; then mount -o ro $mountsrc /mnt/remote elif grep '^Format: confluent_multisquash' /tmp/rootimg.info; then - tail -n +3 /tmp/rootimg.info | awk '{print 0 " " $4 " '$mountsrc' " $3 " " $7}' tail -n +3 /tmp/rootimg.info | awk '{gsub("/", "_"); print "echo 0 " $4 " linear '$mountsrc' " $3 " | dmsetup create mproot" $7}' > /tmp/setupmount.sh . /tmp/setupmount.sh cat /tmp/setupmount.sh |awk '{printf "mount /dev/mapper/"$NF" "; sub("mproot", ""); gsub("_", "/"); print "/mnt/remote"$NF}' > /tmp/mountparts.sh diff --git a/confluent_osdeploy/el8-diskless/profiles/default/scripts/installimage b/confluent_osdeploy/el8-diskless/profiles/default/scripts/installimage index 5edb8f15..234f29ee 100644 --- a/confluent_osdeploy/el8-diskless/profiles/default/scripts/installimage +++ b/confluent_osdeploy/el8-diskless/profiles/default/scripts/installimage @@ -7,8 +7,7 @@ mount -o bind /sys /sysroot/sys mount -o bind /dev /sysroot/dev mount -o bind /proc /sysroot/proc mount -o bind /run /sysroot/run -mkdir -p /sysroot/run/imginst/sourceimage -mount -o bind /mnt/remoteimg /sysroot/run/imginst/sourceimage + if [ ! -f /tmp/mountparts.sh ]; then mkdir -p /sysroot/run/imginst/sources/_