File permissions fix script checks for exfat and other file systems before trying to repair, displays a warning and gives advice on how to fix the issue.
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Controller Tests / controller-tests (push) Waiting to run
Jest Tests / jest-tests (push) Waiting to run

This commit is contained in:
Roland 2026-03-05 18:18:53 -07:00
parent e8bc2b32c4
commit 4008312077
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680

View file

@ -20,15 +20,32 @@ if [ ! -d "${MEDIA_DIRECTORY}" ]; then
exit 1
fi
# Detect the filesystem type of the media directory.
fstype=$(findmnt -n -o FSTYPE --target "${MEDIA_DIRECTORY}" 2>/dev/null)
if [[ "${fstype}" == "vfat" || "${fstype}" == "exfat" || "${fstype}" == "ntfs" || "${fstype}" == "fuseblk" ]]; then
echo "ERROR: ${MEDIA_DIRECTORY} is on a ${fstype} filesystem."
echo ""
echo "FAT, exFAT, and NTFS filesystems do not support Unix file permissions."
echo "Ownership and permissions are controlled by mount options instead."
echo ""
echo "To fix permissions, remount the drive with the correct options:"
echo " sudo mount -o remount,uid=wrolpi,gid=wrolpi ${MEDIA_DIRECTORY}"
echo ""
echo "Or add to /etc/fstab for a permanent fix:"
echo " UUID=<your-drive-uuid> ${MEDIA_DIRECTORY} ${fstype} uid=wrolpi,gid=wrolpi,nofail 0 0"
exit 1
fi
echo "Fixing permissions on ${MEDIA_DIRECTORY}..."
errors=0
dirs_fixed=0
files_fixed=0
# Fix ownership. FAT/exFAT filesystems do not support chown, so warn and continue.
# Fix ownership.
if ! chown -R wrolpi:wrolpi "${MEDIA_DIRECTORY}" 2>/dev/null; then
echo "WARNING: Could not change ownership (filesystem may not support Unix ownership, e.g. FAT/exFAT)."
echo "WARNING: Could not change ownership."
errors=$((errors + 1))
fi
@ -54,7 +71,7 @@ echo "Errors: ${errors}"
if [ "$errors" -gt 0 ]; then
echo ""
echo "Some operations failed. This may be expected on FAT/exFAT filesystems."
echo "Some operations failed."
fi
echo ""