Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tune + fix /usr/sbin/mount-sd.sh #19

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 32 additions & 18 deletions scripts/mount-sd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,35 @@ if [ "$ACTION" = "add" ]; then
exit 0
fi

# This hack is here to delay mounting the sdcard until tracker is ready
case "${TYPE}" in
f2fs)
FSCK_OPTS="-a"
;;
*)
FSCK_OPTS="-p"
;;
esac
fsck $FSCK_OPTS ${DEVNAME}

test -d $MNT/${UUID} || mkdir -p $MNT/${UUID}
chown $DEF_UID:$DEF_GID $MNT $MNT/${UUID}

case "${TYPE}" in
vfat|exfat)
MOUNT_OPTS+=",uid=$DEF_UID,gid=$DEF_GID,utf8,flush,discard"
;;
# NTFS support has not been tested but it's being left to please the ego of an engineer!
ntfs)
MOUNT_OPTS+=",uid=$DEF_UID,gid=$DEF_GID,utf8"
;;
# ext and btrfs are both able to handly TRIM. Add more to the list if needed.
ext4|btrfs|f2fs)
MOUNT_OPTS+=",discard"
;;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identation is a bit off here.

esac
mount ${DEVNAME} $MNT/${UUID} -o $MOUNT_OPTS || /bin/rmdir $MNT/${UUID}

# This hack is here to delay indexing till the tracker has started.
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$DEF_UID/dbus/user_bus_socket
count=1
while true; do
Expand All @@ -43,24 +71,8 @@ if [ "$ACTION" = "add" ]; then
sleep $count ;
count=$(( count + count ))
done

test -d $MNT/${UUID} || mkdir -p $MNT/${UUID}
chown $DEF_UID:$DEF_GID $MNT $MNT/${UUID}
touch $MNT/${UUID}

case "${TYPE}" in
vfat|exfat)
mount ${DEVNAME} $MNT/${UUID} -o uid=$DEF_UID,gid=$DEF_GID,$MOUNT_OPTS,utf8,flush,discard || /bin/rmdir $MNT/${UUID}
;;
# NTFS support has not been tested but it's being left to please the ego of an engineer!
ntfs)
mount ${DEVNAME} $MNT/${UUID} -o uid=$DEF_UID,gid=$DEF_GID,$MOUNT_OPTS,utf8 || /bin/rmdir $MNT/${UUID}
;;
*)
mount ${DEVNAME} $MNT/${UUID} -o $MOUNT_OPTS || /bin/rmdir $MNT/${UUID}
;;
esac
test -d $MNT/${UUID} && touch $MNT/${UUID}

systemd-cat -t mount-sd /bin/echo "Finished ${ACTION}ing ${DEVNAME} of type ${TYPE} at $MNT/${UUID}"

else
Expand All @@ -71,6 +83,8 @@ else
exit 0
fi
umount $DIR || umount -l $DIR
touch ${DIR} # Tell the tracker to reindex.
rmdir ${DIR} # Remove the temporary mount directory.
systemd-cat -t mount-sd /bin/echo "Finished ${ACTION}ing ${DEVNAME} at ${DIR}"
fi
fi
Expand Down