← Documents Documentation/admin-guide/aoe/udev-install.sh GitHub 원문 ↗

Linux 6.18.37 · Admin guide

AoE udev 규칙 설치 스크립트

udev 설정에서 규칙 디렉터리를 찾고 AoE용 `udev.txt`를 `60-aoe.rules`로 설치합니다.

Source pathDocumentation/admin-guide/aoe/udev-install.sh
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

udev-install.sh:1-33

udev 설정에서 규칙 디렉터리를 찾고 AoE용 `udev.txt`를 `60-aoe.rules`로 설치합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 # install the aoe-specific udev rules from udev.txt into
2 # the system's udev configuration
3 #
4
5 me="`basename $0`"
6
7 # find udev.conf, often /etc/udev/udev.conf
8 # (or environment can specify where to find udev.conf)
9 #
10 if test -z "$conf"; then
11 if test -r /etc/udev/udev.conf; then
12 conf=/etc/udev/udev.conf
13 else
14 conf="`find /etc -type f -name udev.conf 2> /dev/null`"
15 if test -z "$conf" || test ! -r "$conf"; then
16 echo "$me Error: no udev.conf found" 1>&2
17 exit 1
18 fi
19 fi
20 fi
21
22 # find the directory where udev rules are stored, often
23 # /etc/udev/rules.d
24 #
25 rules_d="`sed -n '/^udev_rules=/{ s!udev_rules=!!; s!\"!!g; p; }' $conf`"
26 if test -z "$rules_d" ; then
27 rules_d=/etc/udev/rules.d
28 fi
29 if test ! -d "$rules_d"; then
30 echo "$me Error: cannot find udev rules directory" 1>&2
31 exit 1
32 fi
33 sh -xc "cp `dirname $0`/udev.txt $rules_d/60-aoe.rules"
34

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

목적과 설정 탐색 준비

1-9

이 스크립트는 `udev.txt`에 들어 있는 AoE 전용 udev 규칙을 시스템의 udev 설정에 설치합니다. `me`에는 실행 파일의 기본 이름을 저장해 오류 메시지 앞에 붙입니다. 먼저 대개 `/etc/udev/udev.conf`에 있는 `udev.conf`의 위치를 찾되, 환경에서 `conf` 변수를 지정하면 그 위치를 우선 사용합니다.

# install the aoe-specific udev rules from udev.txt into 
# the system's udev configuration
# 

me="`basename $0`"

# find udev.conf, often /etc/udev/udev.conf
# (or environment can specify where to find udev.conf)
#

udev.conf 찾기

10-20

`conf`가 비어 있으면 `/etc/udev/udev.conf`를 읽을 수 있는지 검사하고, 가능하면 그 경로를 사용합니다. 읽을 수 없다면 `/etc` 아래에서 이름이 `udev.conf`인 일반 파일을 찾아 `conf`에 저장하며 검색 오류 출력은 `/dev/null`로 버립니다.

검색 뒤에도 `conf`가 비어 있거나 찾은 파일을 읽을 수 없으면 표준 오류에 `no udev.conf found`를 출력하고 종료 상태 1로 끝냅니다. 환경에서 `conf`가 미리 지정된 경우에는 이 블록을 건너뛰며, 이 스크립트 구간 자체에서는 그 경로의 가독성을 다시 검사하지 않습니다.

udev.conf 선택
conf 환경 변수 있음지정 경로 사용
conf 비어 있음/etc/udev/udev.conf 읽기 가능표준 경로 사용
표준 경로 사용 불가/etc에서 udev.conf 검색읽기 가능 파일검색 결과 사용
결과 없음 또는 읽기 불가오류 메시지exit 1

환경 지정값을 우선하고, 없을 때 표준 위치와 /etc 검색을 차례로 시도합니다.

if test -z "$conf"; then
        if test -r /etc/udev/udev.conf; then
                conf=/etc/udev/udev.conf
        else
                conf="`find /etc -type f -name udev.conf 2> /dev/null`"
                if test -z "$conf" || test ! -r "$conf"; then
                        echo "$me Error: no udev.conf found" 1>&2
                        exit 1
                fi
        fi
fi

규칙 디렉터리 결정과 설치

21-33

선택한 설정 파일에서 줄 시작이 `udev_rules=`인 항목을 `sed`로 찾고, 변수 이름과 큰따옴표를 제거하여 `rules_d`를 얻습니다. 값이 비어 있으면 기본 경로 `/etc/udev/rules.d`를 사용합니다.

결정된 규칙 경로가 디렉터리가 아니면 표준 오류에 udev 규칙 디렉터리를 찾을 수 없다는 메시지를 출력하고 종료 상태 1로 끝냅니다. 유효한 디렉터리이면 현재 스크립트가 있는 디렉터리의 `udev.txt`를 `$rules_d/60-aoe.rules`로 복사합니다. `sh -x`가 실행 명령을 표시하고 `-c`가 문자열 명령을 수행합니다.

udev 규칙 설치 결과
항목
설정 키udev_rules=
기본 규칙 디렉터리/etc/udev/rules.d
입력 파일스크립트 디렉터리/udev.txt
설치 파일$rules_d/60-aoe.rules
실행 방식sh -xc

설정값이 없을 때의 기본값과 최종 복사 대상을 보존합니다.


# find the directory where udev rules are stored, often
# /etc/udev/rules.d
#
rules_d="`sed -n '/^udev_rules=/{ s!udev_rules=!!; s!\"!!g; p; }' $conf`"
if test -z "$rules_d" ; then
        rules_d=/etc/udev/rules.d
fi
if test ! -d "$rules_d"; then
        echo "$me Error: cannot find udev rules directory" 1>&2
        exit 1
fi
sh -xc "cp `dirname $0`/udev.txt $rules_d/60-aoe.rules"