PageRenderTime 41ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/cobol/recipes/microfocus.rb

https://github.com/masamiya/chef-cookbooks
Ruby | 135 lines | 102 code | 8 blank | 25 comment | 1 complexity | f500329a0bc9b2675cdc6cddfe4f4ee9 MD5 | raw file
Possible License(s): Apache-2.0
  1. #
  2. # Cookbook Name:: cobol
  3. # Recipe:: microfocus
  4. #
  5. # Copyright 2014, Biola University
  6. #
  7. # Licensed under the Apache License, Version 2.0 (the "License");
  8. # you may not use this file except in compliance with the License.
  9. # You may obtain a copy of the License at
  10. #
  11. # http://www.apache.org/licenses/LICENSE-2.0
  12. #
  13. # Unless required by applicable law or agreed to in writing, software
  14. # distributed under the License is distributed on an "AS IS" BASIS,
  15. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. # See the License for the specific language governing permissions and
  17. # limitations under the License.
  18. #
  19. include_recipe 'ark::default'
  20. # 'Expect' support
  21. chef_gem 'greenletters'
  22. directory "/opt/microfocus/cobol" do
  23. recursive true
  24. action :create
  25. end
  26. # Server Express install
  27. ark "cobol" do
  28. url node['cobol']['microfocus']['download_url']
  29. checksum node['cobol']['microfocus']['download_checksum']
  30. path '/opt/microfocus'
  31. strip_components 0
  32. action :put
  33. end
  34. ruby_block "install mf cobol" do
  35. block do
  36. require 'greenletters'
  37. installer = Greenletters::Process.new("/opt/microfocus/cobol/install", :transcript => $stdout)
  38. installer.start!
  39. installer.wait_for(:output, /Do you wish to continue \(y\/n\):/i)
  40. installer << "y\n"
  41. installer.wait_for(:output, /Do you agree to the terms of the License Agreement\? \(y\/n\):/i)
  42. installer << "y\n"
  43. installer.wait_for(:output, /Please confirm that you want to continue with this installation \(y\/n\):/i)
  44. installer << "y\n"
  45. installer.wait_for(:output, /Please press return when you are ready:/i)
  46. installer << "\n"
  47. sleep 1
  48. installer << "q"
  49. #installer.wait_for(:output, /Please confirm your understanding of the above reference environment details \(y\/n\):/i)
  50. installer.wait_for(:output, /details \(y\/n\):/i)
  51. installer << "y\n"
  52. installer.wait_for(:output, /Do you want to make use of COBOL and Java working together\? \(y\/n\):/i)
  53. installer << "n\n"
  54. installer.wait_for(:output, /Would you like to install LMF now\? \(y\/n\):/i)
  55. installer << "y\n"
  56. installer.wait_for(:output, /\(Press Enter for default directory \/opt\/microfocus\/mflmf\)/i)
  57. installer << "\n"
  58. installer.wait_for(:output, /do you wish to create it \? \(y\/n\)/i)
  59. installer << "y\n"
  60. installer.wait_for(:output, /Do you want only superuser to be able to access the License Admin System\? \(y\/n\)/i)
  61. installer << "y\n"
  62. installer.wait_for(:output, /Do you want license manager to be automatically started at boot time\? \(y\/n\)/i)
  63. installer << "y\n"
  64. installer.wait_for(:output, /Please enter either 32 or 64 to set the system default mode:/i)
  65. installer << "#{node['cobol']['microfocus']['default_system_mode']}\n"
  66. installer.wait_for(:output, /Do you wish to configure Enterprise Server now\? \(y\/n\):/i)
  67. installer << "n\n"
  68. installer.wait_for(:output, /Do you want to install XDB\? \(y\/n\):/i)
  69. installer << "n\n"
  70. installer.wait_for(:exit)
  71. end
  72. not_if do ::File.directory?('/opt/microfocus/mflmf') end
  73. end
  74. # Start the license manager during the inital install
  75. execute '/etc/mflmrcscript' do
  76. not_if do ::File.directory?('/opt/microfocus/mflmf') end
  77. end
  78. # Setup environment variables
  79. template '/etc/profile.d/mfcobol.sh' do
  80. mode 0755
  81. end
  82. # install EXPRESS license keys
  83. unless node['cobol']['microfocus']['express_license_installed']
  84. ruby_block "install mf cobol express license keys" do
  85. block do
  86. require 'greenletters'
  87. Dir.chdir '/opt/microfocus/mflmf'
  88. installer = Greenletters::Process.new("/opt/microfocus/mflmf/mflmcmd", :transcript => $stdout)
  89. installer.start!
  90. installer.wait_for(:output, /Enter 'U'/i)
  91. installer << "i\n"
  92. installer.wait_for(:output, /Key:/i)
  93. sleep 1
  94. installer << "#{node['cobol']['microfocus']['express_serial_number']}\n"
  95. installer.wait_for(:output, /Key:/i)
  96. sleep 1
  97. installer << "#{node['cobol']['microfocus']['express_license_key']}\n"
  98. installer.wait_for(:exit)
  99. end
  100. end
  101. node.set['cobol']['microfocus']['express_license_installed'] = true
  102. end
  103. # install app license keys
  104. unless node['cobol']['microfocus']['user_license_installed']
  105. ruby_block "install mf cobol user license keys" do
  106. block do
  107. require 'greenletters'
  108. Dir.chdir '/opt/microfocus/cobol/aslmf'
  109. installer = Greenletters::Process.new("/opt/microfocus/cobol/aslmf/apptrack", :transcript => $stdout)
  110. installer.start!
  111. installer.wait_for(:output, /password\)/i)
  112. installer << " "
  113. installer.wait_for(:output, /password/i)
  114. installer << " "
  115. installer.wait_for(:output, /Selection/i)
  116. installer << "3"
  117. installer.wait_for(:output, /Key:/i)
  118. installer << "#{node['cobol']['microfocus']['user_serial_number']}\n"
  119. installer.wait_for(:output, /Key:/i)
  120. installer << "#{node['cobol']['microfocus']['user_license_key']}\n"
  121. installer.wait_for(:output, /Selection/i)
  122. installer << "9"
  123. installer.wait_for(:exit)
  124. end
  125. end
  126. node.set['cobol']['microfocus']['user_license_installed'] = true
  127. end