Differences

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

Link to this comparison view

Next revision
Previous revision
Next revisionBoth sides next revision
zh:docs:guide-user:base-system:hotplug [2019/04/09 08:56] – created czhongmzh:docs:guide-user:base-system:hotplug [2019/04/09 09:28] – [示例] czhongm
Line 41: Line 41:
  
 ^ 变量名 ^ 描述 ^ ^ 变量名 ^ 描述 ^
-| ACTION | Either "add"  or "remove"+| ACTION | "add"  或 "remove"
-| DEVICENAME | seems same as DEVNAME below +| DEVICENAME | 与下面的DEVNAME相同 
-| DEVNAME | Device or partition name (if I connect a drive I get a hotplug call with "sda" and another hotplug call with "sda1")+| DEVNAME | 设备或分区名称(如果连接驱动器,你会得到一个使用“sda”的热插拔调用,另一个使用“sda1”进行热插拔调用)
-| DEVPATH | full device path (for example "/devices/pci0000:00/0000:00:0b.0/usb1/1-1/1-1:1.0/host7/target7:0:0/7:0:0:0/block/sdc/sdc1 " | +| DEVPATH | 完整的设备路径(如 "/devices/pci0000:00/0000:00:0b.0/usb1/1-1/1-1:1.0/host7/target7:0:0/7:0:0:0/block/sdc/sdc1 "
-| DEVTYPE | what the DEVNAME DEVICENAME are names of, I've seen "partition" here when a device with a readable partition is inserted and a "disk" when that device is removed.+| DEVTYPE | DEVNAMEDEVICENAME的名称是什么类型,当插入具有可读分区的设备时,该值为“partition”,当移除该设备时,该值为“disk”。
-| MAJOR | major device number +| MAJOR | 主设备号 
-| MINOR | minor device number +| MINOR | 次要设备号 
-| SEQNUM | seqnum (a number) | +| SEQNUM | 序号(一个数字) | 
-| SUBSYSTEM | seems this is only "block" |+| SUBSYSTEM | 固定值 "block" |
  
 ==== iface 文件夹 ==== ==== iface 文件夹 ====
  
-There are three main environment variables that are passed to each **iface** hotplug script:+传递给每个 **iface** 热插拔脚本有三个主要的环境变量:
 ^ 变量名 ^ 描述 ^ ^ 变量名 ^ 描述 ^
-| ACTION | Either "ifup"  or "ifdown"+| ACTION | "ifup"  或 "ifdown"
-| INTERFACE | Name of the interface which went up or down (e.g. "wan" or "ppp0")+| INTERFACE | 上线或下线的接口名称(例如“wan”或“ppp0”)
-| DEVICE | Physical device name which interface went up or down (e.g. "eth0.1" or "br-lan")|+| DEVICE | 接口上线或下线的物理设备名称(例如“eth0.1”或“br-lan”)|
  
-==== The ntp folder ====+==== ntp 文件夹 ====
  
 ^ 变量名 ^ 描述 ^ ^ 变量名 ^ 描述 ^
-| ACTION | step, stratum, unsync or periodic | +| ACTION | step, stratum, unsync 或 periodic | 
-| freq_drift_ppm | ntp variables +| freq_drift_ppm | ntp 变量 
-| offset | ntp variables +| offset | ntp 变量 
-| stratum | ntp variables +| stratum | ntp 变量 
-| poll_interval | ntp variables |+| poll_interval | ntp 变量 |
  
-Even without NTP sync, you will receive a periodic hotplug event, with stratum=16, about every 11 minutes out of the box.+ 
 +即使没有NTP同步,您也会收到一个定期的热插拔事件,其中stratum=16,开机后大约每11分钟一次。
  
 ==== 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 122: 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 153: Line 154:
 </code> </code>
  
-=== Script that detects if plugged usb device is bluetooth or not. ===+=== 检测插入的usb设备是否蓝牙的脚本 ===
  
 <code bash> <code bash>
Line 180: 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 196: 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 214: 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