]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - config/extrahd/extrahd.pl
suricata: Change midstream policy to "pass-flow"
[people/pmueller/ipfire-2.x.git] / config / extrahd / extrahd.pl
index 145a2a43a1c255ca7f315d4126e4eb7ce5c5f0da..bcde077d0447609495bbacaee7e37f2df9b24ddc 100644 (file)
@@ -35,10 +35,20 @@ extrahd_mount() {
        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
@@ -75,10 +85,20 @@ extrahd_umount() {
        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
 
                # Do not try to umount if nothing is mounted
                if ! mountpoint "${mountpoint}" &>/dev/null; then
@@ -96,7 +116,21 @@ extrahd_umount() {
        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
 
@@ -109,6 +143,9 @@ main() {
                umount)
                        extrahd_umount "${@}" || rc="${rc}"
                        ;;
+               udev-event)
+                       handle_udev_event "${@}" || rc="${rc}"
+                       ;;
                scanhd)
                        exec /usr/local/bin/scanhd "${@}"
                        ;;