template으로 배포 시에는 문제가 없으나 file로 배포 시에 문제가 발생하는 경우가 있습니다.

/bin/sh^M: bad interpreter: No such file or directory

 

이 문제는 dos, uinx간 파일 포맷 오류로 dos2unix를 사용하거나 vi에서 set ff=unix로 설정하는 방법 등이 있습니다.

그래서 아래와 같이 문제를 방어하도록 구현하였습니다.

bash 'file_format_to_unix' do
  code <<-EOH
    vi -c "set ff=unix" -c "wq" #{dir}/#{file}
  EOH
end