/home/ 아래의 "Documents" 폴더만 내보내는 방법?

/home/ 아래의 "Documents" 폴더만 내보내는 방법?

모든 사용자에 대해 "/home/%USER%/Documents" 폴더를 내보내면 됩니다. /etc/exports 파일을 어떻게 구성합니까?

시스템: CentOS 7 서비스: NFS 서버

/etc/exports에서 정규식 구문을 사용해 보았습니다.

/home/*/Documents    *(rw,sysc,no_roo_squash)
/home/\*/Documents    *(rw,sysc,no_roo_squash)

하지만 작동하지 않습니다.

답변1

와일드카드는 지원되지 않으므로 /etc/exports간단히 스크립트를 실행하여 /etc/exports필요한 모든 행을 자동으로 생성할 수 있습니다. 스크립트는 아래 예와 같을 수 있으며 매일 cronjob을 통해 실행하여 사용자 추가 또는 제거를 위한 내보내기를 업데이트할 수도 있습니다.

grep -v "^/home/.*/Documents\b" /etc/exports > /etc/exports.new
find /home/ -mindepth 2 -maxdepth 2 -type d -name Documents  \
    | sed 's/$/ *(rw,sysc,no_root_squash)/' >> /etc/exports.new
mv /etc/exports.new /etc/exports
exportfs -ra

관련 정보