Skip to content

Commit

Permalink
⬆️ Bump cOS
Browse files Browse the repository at this point in the history
Signed-off-by: GitHub <noreply@github.com>
  • Loading branch information
mudler authored Jul 12, 2022
1 parent 132897c commit cf881d2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,53 +1,45 @@
#!/bin/bash

function doLoopMount {
local label
local partdev
local partname
local dev

# Iterate over current device labels
for dev in /dev/disk/by-label/*; do
label=$(basename "${dev}")
[ -e "/tmp/cosloop-${label}" ] && continue
> "/tmp/cosloop-${label}"
for partdev in $(lsblk -ln -o path,type | grep part | cut -d" " -f1); do
partname=$(basename "${partdev}")
[ -e "/tmp/cosloop-${partname}" ] && continue
> "/tmp/cosloop-${partname}"

mount -t auto -o "${cos_root_perm}" "/dev/disk/by-label/${label}" "${cos_state}" || continue
if [ -f "${cos_state}/${cos_img}" ]; then
# Ensure run system-fsck, at least, for the root partition
systemd-fsck "${partdev}"

# Only run systemd-fsck if root is already found
[ "${found}" == "ok" ] && continue

# FSCHECK if cos_root_perm == "ro" on both
if [ "$cos_root_perm" == "ro" ]; then
systemd-fsck "/dev/disk/by-label/${label}"
fi
mount -t auto -o "${cos_root_perm}" "${partdev}" "${cos_state}" || continue
if [ -f "${cos_state}/${cos_img}" ]; then

dev=$(losetup --show -f "${cos_state}/${cos_img}")

# FSCHECK if cos_root_perm == "ro"
if [ "$cos_root_perm" == "ro" ]; then
systemd-fsck "$dev"
fi
# attempt to run systemd-fsck on the loop device
systemd-fsck "${dev}"

exit 0
found="ok"
else
umount "${cos_state}"
fi
done
}

function dofsCheck {
# Iterate over current partitions
# As fs corruption could lead to partitions with no label, we scan here for all partitions found and we run systemd-fsck
for dev in /dev/disk/by-partuuid/*; do
partuuid=$(basename "${dev}")
systemd-fsck "/dev/disk/by-partuuid/${partuuid}"
done
}

type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh

PATH=/usr/sbin:/usr/bin:/sbin:/bin

declare cos_img=$1
declare cos_root_perm="ro"
declare cos_state="/run/initramfs/cos-state"
declare found=""

[ -z "${cos_img}" ] && exit 1

Expand All @@ -59,8 +51,10 @@ ismounted "${cos_state}" && exit 0

mkdir -p "${cos_state}"

dofsCheck
doLoopMount
if [ "${found}" == "ok" ]; then
exit 0
fi

rm -r "${cos_state}"
exit 1
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ install() {
declare initdir="${initdir}"

inst_multiple \
mount mountpoint elemental sort findmnt rmdir findmnt rsync
mount mountpoint elemental sort findmnt rmdir findmnt rsync cut

# Include utilities required for cos-setup services,
# probably a devoted cos-setup dracut module makes sense
Expand All @@ -44,4 +44,4 @@ install() {
ln_r "$systemdutildir"/systemd-fsck \
"/sbin/systemd-fsck"
dracut_need_initqueue
}
}

0 comments on commit cf881d2

Please sign in to comment.