Skip to content

Commit

Permalink
Merge pull request #354 from aafeijoo-suse/059-convertfs-fix
Browse files Browse the repository at this point in the history
fix(convertfs): error in conditional expressions (bsc#1228847)
  • Loading branch information
aafeijoo-suse authored Aug 7, 2024
2 parents 20b345b + 265ef8e commit d445b0d
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions modules.d/30convertfs/convertfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ while [[ $ROOT != "${ROOT%/}" ]]; do
done

#mount /sysroot rw
[ -w $ROOT ] || mount -o remount,rw $ROOT
[[ -w $ROOT ]] || mount -o remount,rw "$ROOT"

#mount /sysroot/var if it is a separate mount
VARDEV=$(sed -n -e 's/^\#.*//' -e '/ \/var /s/\([[:graph:]]* \).*/\1/p' /sysroot/etc/fstab)
VARFS=$(sed -n -e 's/^\#.*//' -e '/ \/var /s/[[:graph:]]* * [[:graph:]]* *\([[:graph:]]* \).*/\1/p' /sysroot/etc/fstab)
VARDEV=$(sed -n -e 's/^\#.*//' -e '/ \/var /s/\([[:graph:]]* \).*/\1/p' "$ROOT"/etc/fstab)
VARFS=$(sed -n -e 's/^\#.*//' -e '/ \/var /s/[[:graph:]]* * [[:graph:]]* *\([[:graph:]]* \).*/\1/p' "$ROOT"/etc/fstab)

if [ -n $VARDEV ] && [ -n $VARFS ]; then
if [[ -n $VARDEV ]] && [[ -n $VARFS ]]; then
#mount btrfs subvolume var
if [ $VARFS == btrfs ]; then
SUBVOLIDVAR=$(btrfs subvolume list $ROOT | sed -n '/var$/s/ID \([[:digit:]]*\) .*/\1/p')
if [[ $VARFS == btrfs ]]; then
SUBVOLIDVAR=$(btrfs subvolume list "$ROOT" | sed -n '/var$/s/ID \([[:digit:]]*\) .*/\1/p')
ROOTDEV=$(sed -n "/\\$ROOT/s/\([[:graph:]]*\) .*/\1/p" /proc/mounts)
[ -z $SUBVOLIDVAR ] || mount -o subvolid=$SUBVOLIDVAR $ROOTDEV $ROOT/var
[[ -z $SUBVOLIDVAR ]] || mount -o subvolid="$SUBVOLIDVAR" "$ROOTDEV" "$ROOT"/var
else
mount $VARDEV $ROOT/var
mount "$VARDEV" "$ROOT"/var
fi
fi

Expand All @@ -50,8 +50,8 @@ if [ ! -L "$ROOT"/var/lock -a -e "$ROOT"/var/lock ]; then
ln -sfn ../run/lock "$ROOT"/var/lock
fi

[ -n $SUBVOLIDVAR ] && umount $ROOT/var
[ -w $ROOT ] && mount -o remount,ro $ROOT
[[ -n $SUBVOLIDVAR ]] && umount "$ROOT"/var
[[ -w $ROOT ]] && mount -o remount,ro "$ROOT"

echo "Done."
exit 0

0 comments on commit d445b0d

Please sign in to comment.