_ssh-ident.rb 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #
  2. # Cookbook:: workstation
  3. # Recipe:: _ssh-ident
  4. #
  5. # Copyright:: 2022, The Authors, All Rights Reserved.
  6. username = node['my_workstation']['default_user'].first[0]
  7. user_repo_directory = ::File.join(node['my_workstation']['default_user'][username]['home'], 'repo')
  8. ssh_ident_repo = ::File.join(user_repo_directory, 'ssh-ident')
  9. ssh_ident_bin = ::File.join(ssh_ident_repo, 'ssh-ident')
  10. patch_file = '001-ssh_ident-fix-python.patch'
  11. git ssh_ident_repo do
  12. repository 'https://github.com/ccontavalli/ssh-ident'
  13. user username
  14. action :checkout
  15. end
  16. cookbook_file ::File.join(ssh_ident_repo, patch_file) do
  17. source patch_file
  18. owner username
  19. group username
  20. notifies :run, "execute[git am #{patch_file}]", :immediately
  21. end
  22. # How to create a git patch:
  23. # Ref: https://devconnected.com/how-to-create-and-apply-git-patch-files/
  24. execute "git am #{patch_file}" do
  25. cwd ssh_ident_repo
  26. action :nothing
  27. end
  28. execute "/usr/bin/install #{ssh_ident_bin} /usr/sbin/ssh-ident" do
  29. not_if { ::FileUtils.uptodate?('/usr/sbin/ssh-ident', [ssh_ident_bin]) }
  30. end