Update mdev/dmcache.mdev

Add license identifier and description.
This commit is contained in:
Forza 2023-11-24 10:11:37 +01:00
parent ce178b3b35
commit da9ac7e87d

View File

@ -1,25 +1,30 @@
#!/bin/sh #!/bin/sh
uuid_file="/etc/dmcache-uuids" # mdev script to mask dm-cache origin device's FS UUID
#
# Check if the file exists # SPDX-License-Identifier: GPL-3.0-or-later
if [ ! -f "$uuid_file" ]; then # Copyright 2023 Forza <forza@tnonline.net>
echo "Error: File '$uuid_file' not found."
exit 1 uuid_file="/etc/dmcache-uuids"
fi
# Check if the file exists
# Loop through each UUID in the file and remove the corresponding symlink if [ ! -f "$uuid_file" ]; then
while IFS= read -r uuid; do echo "Error: File '$uuid_file' not found."
exit 1
if [ -z "$uuid" ] || [ "${uuid:0:1}" = "#" ]; then fi
continue
fi # Loop through each UUID in the file and remove the corresponding symlink
while IFS= read -r uuid; do
symlink="/dev/disk/by-uuid/$uuid"
if [ -z "$uuid" ] || [ "${uuid:0:1}" = "#" ]; then
# Check if the symlink exists continue
if [ -L "$symlink" ]; then fi
echo "Removing symlink: $symlink"
rm "$symlink" symlink="/dev/disk/by-uuid/$uuid"
fi
done < "$uuid_file" # Check if the symlink exists
if [ -L "$symlink" ]; then
echo "Removing symlink: $symlink"
rm "$symlink"
fi
done < "$uuid_file"