SHARE
TWEET

Untitled

a guest Oct 21st, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [maarsytest 2:49] ~> cat /usr/local/libexec/usbserialsn
  2. #!/bin/sh
  3.  
  4. if [ $# -lt 2 ]; then
  5.   echo "Bad usage"
  6.   exit 1
  7. fi
  8.  
  9. mode=$1
  10. devname=$2
  11. sernum=$3
  12. ttyname=$4
  13.  
  14. case "$mode" in
  15.   attach)
  16.     if [ $# -ne 4 ]; then
  17.       echo "Bad usage"
  18.       exit 1
  19.     fi
  20.     ln -sf cua${ttyname} /dev/cu.${sernum}
  21.     ln -sf tty${ttyname} /dev/tty.${sernum}
  22.     echo ${sernum} >/var/run/usbserialsn.${devname}
  23.     ;;
  24.  
  25.   detach)
  26.     if [ $# -ne 2 ]; then
  27.       echo "Bad usage"
  28.       exit 1
  29.     fi
  30.     if [ ! -e /var/run/usbserialsn.${devname} ]; then
  31.       exit 0
  32.     fi
  33.     sernum=$(cat /var/run/usbserialsn.${devname})
  34.     rm -f /dev/cu.${sernum} /dev/tty.${sernum} /var/run/usbserialsn.${devname}
  35.     ;;
  36.  
  37.   *)
  38.     echo "Unknown mode"
  39.     exit 1
  40.     ;;
  41. esac
  42.  
  43. [maarsytest 2:49] ~> cat /usr/local/etc/devd/usbserialsn.conf
  44. attach 100 {
  45.     device-name     ".*";
  46.     match "ttyname"     ".+";
  47.     match "ugen"        ".+";
  48.     match "sernum"      ".+";
  49.     action "/usr/local/libexec/usbserialsn attach $device-name $sernum $ttyname";
  50. };
  51.  
  52. detach 100 {
  53.     device-name     ".*";
  54.     action "/usr/local/libexec/usbserialsn detach $device-name";
  55. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top