installer.rb 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/usr/bin/env ruby
  2. require "./lib/core"
  3. require "./lib/config"
  4. module OSPatch
  5. def check_linux_debian?
  6. return File.exist?("/etc/debian_version")
  7. end
  8. def check_os
  9. case RUBY_PLATFORM.downcase
  10. when /darwin/
  11. @osname = "MacOS"
  12. when /ubuntu/i
  13. @osname = "DebianLinux"
  14. when /debian/i
  15. @osname = "DebianLinux"
  16. # when /centos/i
  17. # @osname = "CentOS"
  18. # when /fedora/i
  19. # @osname = "Fedora"
  20. # when /redhat/i
  21. # @osname = "Red Hat"
  22. # when /suse/i
  23. # @osname = "SUSE"
  24. # when /unix/
  25. # @osname = "unix"
  26. when /mswin|win32|mingw|cygwin/
  27. @osname = "win"
  28. not_support_exit
  29. else
  30. not_support_exit
  31. end
  32. end
  33. end
  34. module RimeDeploy
  35. class Installer
  36. include OSPatch
  37. def initialize
  38. @osname = nil
  39. check_os
  40. dispatch
  41. run
  42. end
  43. def not_support_exit
  44. puts "Not support this system. Bye~"
  45. exit 0
  46. end
  47. def dispatch
  48. require "./os/#{@osname}"
  49. end
  50. def run
  51. os_prefix = @osname
  52. code = <<-CODE
  53. class #{os_prefix}JobGroup < JobGroup
  54. end
  55. mod = #{os_prefix}JobGroup.new(#{os_prefix}::Jobs, #{os_prefix}::FinishedHook)
  56. mod.call
  57. CODE
  58. instance_eval(code)
  59. end
  60. end
  61. end
  62. RimeDeploy::Installer.new