local failed=0
while IFS=';' read -r device filesystem mountpoint rest; do
- # Filter by mountpoint if set
- if [ -n "${_mountpoint}" ] && [ "${mountpoint}" != "${_mountpoint}" ]; then
- continue
- fi
+ # Filter by UUID or mountpoint
+ case "${_mountpoint}" in
+ UUID=*)
+ if [ "${device}" != "${_mountpoint}" ]; then
+ continue
+ fi
+ ;;
+
+ /*)
+ if [ -n "${_mountpoint}" ] && [ "${mountpoint}" != "${_mountpoint}" ]; then
+ continue
+ fi
+ ;;
+ esac
# Check that the mountpoint starts with a slash
if [ "${mountpoint:0:1}" != "/" ]; then
local failed=0
while IFS=';' read -r device filesystem mountpoint rest; do
- # Filter by mountpoint if set
- if [ -n "${_mountpoint}" ] && [ "${mountpoint}" != "${_mountpoint}" ]; then
+ # Filter by UUID or mountpoint
+ case "${_mountpoint}" in
+ UUID=*)
+ if [ "${device}" != "${_mountpoint}" ]; then
+ continue
+ fi
+ ;;
+
+ /*)
+ if [ -n "${_mountpoint}" ] && [ "${mountpoint}" != "${_mountpoint}" ]; then
+ continue
+ fi
+ ;;
+ esac
+
+ # Do not try to umount if nothing is mounted
+ if ! mountpoint "${mountpoint}" &>/dev/null; then
continue
fi
done < /var/ipfire/extrahd/devices
}
+handle_udev_event() {
+ case "${ACTION}" in
+ add)
+ if [ -n "${ID_FS_UUID}" ]; then
+ extrahd_mount "UUID=${ID_FS_UUID}" || return $?
+ fi
+ ;;
+ esac
+
+ return 0
+}
+
main() {
+ ( echo "$@"; set ) > /tmp/extrahd.$$
+
local command="${1}"
shift
umount)
extrahd_umount "${@}" || rc="${rc}"
;;
+ udev-event)
+ handle_udev_event "${@}" || rc="${rc}"
+ ;;
scanhd)
exec /usr/local/bin/scanhd "${@}"
;;