Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
zh:docs:guide-user:base-system:hotplug [2019/04/09 09:12] – [The ntp folder] czhongmzh:docs:guide-user:base-system:hotplug [2019/04/09 09:28] – [示例] czhongm
Line 73: Line 73:
 ==== usb 文件夹 ==== ==== usb 文件夹 ====
 ^ 变量名 ^ 描述 ^ ^ 变量名 ^ 描述 ^
-| ACTION | add, remove as above +| ACTION | add, remove 如上 
-| DEVNAME | eg, "bus/usb/001/002"+| DEVNAME | 如 "bus/usb/001/002"
-| DEVPATH | eg, "/devices/platform/ehci-platform/usb1/1-1"+| DEVPATH | 如 "/devices/platform/ehci-platform/usb1/1-1"
-| DEVICENAME | eg "1-1"+| DEVICENAME | 如 "1-1"
-| DEVNUM | eg 002 |+| DEVNUM | 如 002 |
 | DRIVER | "usb" | | DRIVER | "usb" |
-| TYPE | eg 9/0/1 | +| TYPE | 如 9/0/1 | 
-| PRODUCT | the vendor/productcode/versioneg "424/2640/0" see lsusb +| PRODUCT | 供应商/产品代码/版本如用lsusb看到的 "424/2640/0"
-| SEQNUM | ? eg 335 | +| SEQNUM | ? 如 335 | 
-| BUSNUM | eg 001 | +| BUSNUM | 如 001 | 
-| MAJOR | eg 189 | +| MAJOR | 如 189 | 
-| MINOR | eg 1 |+| MINOR | 如 1 |
  
 ===== 示例 ===== ===== 示例 =====
Line 123: Line 123:
 === 符号链接代替设备重命名 === === 符号链接代替设备重命名 ===
  
-An other script to create a symlink instead of renaming the device.\\ +另一个用于创建符号链接而不是重命名设备的脚本。\\ 
-I test if DEVICE_NAME is empty because when I plug usb device I retrieve two add event, and the first come before created device, so symlink fails.+因为当我插入一个usb设备时会收到2个add事件,而为了确保在创建符号链接前设备已经创建,我在这里增加了一个判断DEVICE_NAME是否为空.
 <code bash> <code bash>
 cat << "EOF" > /etc/hotplug.d/usb/20-cp210x cat << "EOF" > /etc/hotplug.d/usb/20-cp210x
Line 154: Line 154:
 </code> </code>
  
-=== Script that detects if plugged usb device is bluetooth or not. ===+=== 检测插入的usb设备是否蓝牙的脚本 ===
  
 <code bash> <code bash>
Line 181: Line 181:
 </code> </code>
  
-=== Auto start mjpg-streamer when an usb camera is plugged in. ===+=== 当usb摄像头插入时自动启动mjpg-streamer ===
 <code bash> <code bash>
 cat << "EOF" > /etc/hotplug.d/usb/20-mjpg_start cat << "EOF" > /etc/hotplug.d/usb/20-mjpg_start
Line 197: Line 197:
 </code> </code>
  
-=== Custom automount script for xfs ===+=== xfs的自定义自动挂载脚本 ===
 <code bash> <code bash>
 cat << "EOF" > /etc/hotplug.d/block/xfs_automount cat << "EOF" > /etc/hotplug.d/block/xfs_automount
-if a new block device is connected+如果新的block设备已连接
 if [ "$ACTION" = "add" ] ; then if [ "$ACTION" = "add" ] ; then
-    # getting device UUID+    # 获取设备 UUID
     detected_uuid=$( xfs_admin -u /dev/$DEVICENAME | awk '{print $3}' )     detected_uuid=$( xfs_admin -u /dev/$DEVICENAME | awk '{print $3}' )
-    # deciding mountpoint for known UUID+    # 确定已知UUID的挂载点
     mountpoint=""     mountpoint=""
     case "$detected_uuid" in     case "$detected_uuid" in
Line 215: Line 215:
    esac    esac
  
-   # if we have a known UUID we have a mountpoint so we can mount it+   # 如果有一个挂载点,则挂载它
    if [ "$mountpoint" != "" ] ; then     if [ "$mountpoint" != "" ] ; then 
        mount /dev/$DEVICENAME $mountpoint        mount /dev/$DEVICENAME $mountpoint
    fi    fi
 fi fi
-unmounting happens automatically at device disconnection anyway so no logic for that+无论如何,卸载在设备断开时自动发生,因此没有逻辑操作
 EOF EOF
 </code> </code>
  • Last modified: 2019/04/09 09:34
  • by czhongm