Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revisionBoth sides next revision
zh:docs:guide-user:base-system:hotplug [2019/04/09 09:14] – [usb 文件夹] czhongmzh:docs:guide-user:base-system:hotplug [2019/04/09 09:28] – [示例] czhongm
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