_ssh-ident.rb 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. git ssh_ident_repo do
  11. repository 'https://github.com/ccontavalli/ssh-ident'
  12. user username
  13. action :checkout
  14. not_if { ::File.exists?(ssh_ident_repo) }
  15. end
  16. # How to create a git patch:
  17. # Ref: https://devconnected.com/how-to-create-and-apply-git-patch-files/
  18. patch_files = %w{
  19. 001-ssh_ident-fix-python.patch
  20. 0001-fix-timeout-Increase-the-ssh-key-in-memory-timeout-t.patch
  21. }
  22. patch_files.each do |patch_file|
  23. cookbook_file ::File.join(ssh_ident_repo, patch_file) do
  24. source patch_file
  25. owner username
  26. group username
  27. end
  28. execute "git am #{patch_file}" do
  29. cwd ssh_ident_repo
  30. only_if "/usr/bin/git apply #{patch_file} --check"
  31. end
  32. end
  33. execute "/usr/bin/install #{ssh_ident_bin} /usr/sbin/ssh-ident" do
  34. not_if { ::FileUtils.uptodate?('/usr/sbin/ssh-ident', [ssh_ident_bin]) }
  35. end