mount_digiparts.sh: add unit running check for systemd devices

For devices running 'systemd', the mount process is done through 'systemd-mount', which
spawns a system unit. Trying to mount the partition again throws an error stating that a
unit with the same name is already running. To avoid it, check if the unit is already
spawned before mounting the partition and, if so, just restart the unit.

Signed-off-by: David Escalona <david.escalona@digi.com>
This commit is contained in:
David Escalona 2023-03-24 12:29:05 +01:00
parent 060e2f4fe1
commit bf88deb602
1 changed files with 10 additions and 0 deletions

View File

@ -53,6 +53,16 @@ fi
if [ "x$BASE_INIT" = "x$INIT_SYSTEMD" ];then
# systemd as init uses systemd-mount to mount block devices
# Verify if unit is already launched, if so just restart it.
if systemctl | grep -q "mnt-${PARTNAME}.mount"; then
if ! systemctl restart "mnt-${PARTNAME}.mount"; then
logger -t udev "ERROR: Could not mount '${DEVNAME}'"
exit 1
fi
exit 0
fi
MOUNT="/usr/bin/systemd-mount"
MOUNT_PARAMS="${MOUNT_PARAMS} --no-block"