2015-01-23 3 views
1

저는 웹 서버 (gitolite를 실행 중)에 git 저장소를 delpoys하는 루비 스크립트를 post-recieve 후크와 함께 사용했습니다.Ruby chmod는 "js /"라는 하나의 디렉토리가 아닙니다.

파일을 체크 아웃 한 후이 같은 후 chmod에 먼저 디렉토리 및 파일을보십시오

FileUtils.chmod_R(0755, Dir.glob("#{deploy_to_dir}/**/*/")) 
FileUtils.chmod_R(0644, Dir.glob("#{deploy_to_dir}/**/*")) 

첫 번째 명령은 모든 디렉토리에 대한 작동하지만 하나 js/합니다. 이 디렉토리에 +x을 설정하지 마십시오. 동시에 +r을 설정하십시오.

여기 무슨 일이야 :

  1. 하기 전에 예상 drw-r--r-- js/
  2. : dr-------- js/
  3. 걙먡 ꍲ 뱭이 후 js/
  4. chmod 755을 수행

drwxr-xr-x js/은 무형 문화 유산 lsattr으로 arrtibutes를 확인했습니다. 그것은 단지 특별한 것을 보여주지 않는 -----------------e- ./js/을 준다. 잘못 될 수있는 것이 있습니까?

bash에서 직접 변경하면 올바르게 작동합니다. Ruby가이 단일 디렉토리에 대해 수행하는 작업은 무엇입니까? 순서를 반대로

+1

여기서'js /'는 디렉토리 구조에 있습니까? –

+0

두 번째 chmod 호출은 x 비트를 설정 해제하고 js 디렉토리에 적용하는 것처럼 보입니다. 이 모든 코드입니까? dir과 파일을 구분하는 스크립트는 무엇입니까? – iamnotmaynard

+0

@HunterMcMillen js /는 첫 번째 단계입니다. 그래서'# {deploy_to_dir} '에 있습니다. – Florian

답변

0

결국 glob의 첫 번째 디렉토리는 js/ 또는 en/입니다. =>이제는 bash 스크립트이고 작동합니다.

#!/bin/bash 
# post-receive 

# 1. Read STDIN (Format: "from_commit to_commit branch_name") 
read from to branch 

if [[ $branch =~ master$ ]] ; then 
    deploy_to_dir='/var/www/virtual/whnr/vectoflow' 
    GIT_WORK_TREE="$deploy_to_dir" git checkout -f master 
elif [[ $branch =~ development$ ]] ; then 
    deploy_to_dir='/var/www/virtual/whnr/vectotest' 
    GIT_WORK_TREE="$deploy_to_dir" git checkout -f development 
else 
    echo "Received branch $branch, not deploying." 
    exit 0 
fi 

# 3. chmod +r whole deploy_to_dir 
find $deploy_to_dir -type d -print0 | xargs -0 chmod 755 
echo "DEPLOY: Changed Permissions on all directories 755" 
find $deploy_to_dir -type f -print0 | xargs -0 chmod 644 
echo "DEPLOY: Changed Permissions on all files 644" 
0

시도 :

FileUtils.chmod_R(0644, Dir.glob("#{deploy_to_dir}/**/*")) 
FileUtils.chmod_R(0755, Dir.glob("#{deploy_to_dir}/**/*/")) 

그렇지 않으면 모든 파일과 디렉토리가 0644 chmod 일치하고 실행 비트를 취소됩니다.

+0

그건 진짜 문제가 아니야. 글로브는 파일과 디렉토리에서만 작동했습니다. 다른 모든 파일에 대해서는 정상적으로 작동했습니다. – Florian