_ssh-ident.rb 1.1 KB

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