extrahd: add forgotten udev_event handler to mount partitions via udev

Message ID 20230927150408.3190-1-arne_f@ipfire.org
State Accepted
Commit 90147c2c330eccc64391cd05e5f2427d3ae11160
Headers
Series extrahd: add forgotten udev_event handler to mount partitions via udev |

Commit Message

Arne Fitzenreiter Sept. 27, 2023, 3:04 p.m. UTC
  Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
---
 config/extrahd/extrahd.pl | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
  

Comments

Michael Tremer Sept. 28, 2023, 9:38 a.m. UTC | #1
I have merged this into core 180 as a hotfix.

> On 27 Sep 2023, at 16:04, Arne Fitzenreiter <arne_f@ipfire.org> wrote:
> 
> Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
> ---
> config/extrahd/extrahd.pl | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
> 
> diff --git a/config/extrahd/extrahd.pl b/config/extrahd/extrahd.pl
> index cc85228d5..bcde077d0 100644
> --- a/config/extrahd/extrahd.pl
> +++ b/config/extrahd/extrahd.pl
> @@ -116,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
> 
> @@ -129,6 +143,9 @@ main() {
> umount)
> extrahd_umount "${@}" || rc="${rc}"
> ;;
> + udev-event)
> + handle_udev_event "${@}" || rc="${rc}"
> + ;;
> scanhd)
> exec /usr/local/bin/scanhd "${@}"
> ;;
> -- 
> 2.38.1
>
  

Patch

diff --git a/config/extrahd/extrahd.pl b/config/extrahd/extrahd.pl
index cc85228d5..bcde077d0 100644
--- a/config/extrahd/extrahd.pl
+++ b/config/extrahd/extrahd.pl
@@ -116,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
 
@@ -129,6 +143,9 @@  main() {
 		umount)
 			extrahd_umount "${@}" || rc="${rc}"
 			;;
+		udev-event)
+			handle_udev_event "${@}" || rc="${rc}"
+			;;
 		scanhd)
 			exec /usr/local/bin/scanhd "${@}"
 			;;