now that there is a dedicated place for examples,
i think it would be easier to get started
with hotplugd/attach with a file instead of
copy pasting from the manual page...

the only difference from the man page example
is simple logging with logger(1) (to help add
new devices), and commenting out (but leaving
for reference) the sony camera example.


i think it would be useful to somehow
advertise these examples (perhaps a reference
in their respective man files) as they are
easy to overlook, especially for newcomers,
and could save some d'oh moments...

-f


Index: etc/examples/attach
===================================================================
RCS file: etc/examples/attach
diff -N etc/examples/attach
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ etc/examples/attach 24 Dec 2014 09:58:07 -0000
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+DEVCLASS=$1
+DEVNAME=$2
+
+logger -i -t attach "DEVCLASS=$DEVCLASS, DEVNAME=$DEVNAME"
+
+case $DEVCLASS in
+2)
+       # disk devices
+       disklabel=`/sbin/disklabel $DEVNAME 2>&1 | \
+               sed -n '/^label: /s/^label: //p'`
+       logger -i -t attach "disklabel='$disklabel'"
+#      case $disklabel in
+#      Sony*DSC*)
+#              mount -o nodev,nosuid /dev/"$DEVNAME"i /mnt/camera
+#              ;;
+#      esac
+       ;;
+3)
+       # network devices; requires hostname.$DEVNAME
+       sh /etc/netstart $DEVNAME
+       ;;
+esac
Index: usr.sbin/hotplugd/hotplugd.8
===================================================================
RCS file: /cvs/src/usr.sbin/hotplugd/hotplugd.8,v
retrieving revision 1.12
diff -u -p -r1.12 hotplugd.8
--- usr.sbin/hotplugd/hotplugd.8        21 Jan 2014 03:15:46 -0000      1.12
+++ usr.sbin/hotplugd/hotplugd.8        24 Dec 2014 09:58:10 -0000
@@ -85,34 +85,6 @@ Script to execute on device attachment.
 .It /etc/hotplug/detach
 Script to execute on device detachment.
 .El
-.Sh EXAMPLES
-Sample
-.Pa attach
-script:
-.Bd -literal -offset indent
-#!/bin/sh
-
-DEVCLASS=$1
-DEVNAME=$2
-
-case $DEVCLASS in
-2)
-       # disk devices
-       disklabel=`/sbin/disklabel $DEVNAME 2\*(Gt&1 | \e
-           sed -n '/^label: /s/^label: //p'`
-       case $disklabel in
-       Sony*DSC*)
-               # Sony DSC camera
-               mount -o nodev,nosuid /dev/"$DEVNAME"i /mnt/camera
-               ;;
-       esac
-       ;;
-3)
-       # network devices; requires hostname.$DEVNAME
-       sh /etc/netstart $DEVNAME
-       ;;
-esac
-.Ed
 .Sh SEE ALSO
 .Xr hotplug 4
 .Sh HISTORY

Reply via email to