Module: Deployman::App::Install
- Defined in:
- lib/deployman/app/install.rb
Constant Summary collapse
- DL_DIR =
"/tmp/"- @@options =
{}
Class Method Summary collapse
-
.create_configfile(owner, software, release, zip_url, dest) ⇒ Object
CREATE CONFIGFILE.
-
.createfiles_from_api(dest) ⇒ Object
CREATE FILES FROM API.
-
.deployrb(dest) ⇒ Object
RUN_DEPLOYRB dest = “/sandbox/liveserver/customerName/software/repoOnwer/repoName/releases/v2.2.0”.
-
.install(owner, software, release, zip_url, dest, auth = false) ⇒ Object
INSTALL owner = “repoOwner” software = “repoName” release = “v2.2.0” zip_url = “api.github.com/repos/repoOnwer/repoName/zipball/v2.2.0” dest = “/sandbox/liveserver/customerName/software/repoOnwer/repoName/releases/v2.2.0”.
- .run(options) ⇒ Object
-
.uninstall(release_path) ⇒ Object
UNINSTALL release_path = “/sandbox/liveserver/customerName/software/repoOnwer/repoName/releases/v2.2.0”.
Class Method Details
.create_configfile(owner, software, release, zip_url, dest) ⇒ Object
CREATE CONFIGFILE
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/deployman/app/install.rb', line 92 def self.create_configfile (owner, software, release, zip_url, dest) begin config = { "owner" => owner, "software" => software, "version" => release, "installed_at" => DateTime.now.strftime("%b %d, %Y %H:%M"), "zip_url" => zip_url, "dest" => dest } config.merge! [:config] Deployman::App::Configuration.create(dest, config) rescue Exception => e warn "ERROR: #{e.message}" raise "Creating Configfile failed!" end end |
.createfiles_from_api(dest) ⇒ Object
CREATE FILES FROM API
112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/deployman/app/install.rb', line 112 def self.createfiles_from_api (dest) begin # foreach all fileUrls [:createfiles_from_api].each do |fileUrl| # get file data from api request data = Deployman::Net::Get.send fileUrl # create file Deployman::Component::Filemanager.create_file(dest + '/' + data['path'], data['content']) end rescue Exception => e warn "ERROR: #{e.message}" raise "Creating Files from API failed!" end end |
.deployrb(dest) ⇒ Object
RUN_DEPLOYRB dest = “/sandbox/liveserver/customerName/software/repoOnwer/repoName/releases/v2.2.0”
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/deployman/app/install.rb', line 130 def self.deployrb (dest) begin deployrb_path = dest + "/deploy.rb" if File.exist?(deployrb_path) # execute deploy.rb Deployman::Component::Spinningclock.show_clock { # get config $config = Deployman::App::Configuration.get(dest) # change to release dir Dir.chdir dest # run deploy.rb load deployrb_path } else print "(no deploy.rb file)..." end rescue Exception => e warn "ERROR: #{e.message}" raise "Deploying failed!" end end |
.install(owner, software, release, zip_url, dest, auth = false) ⇒ Object
INSTALL owner = “repoOwner” software = “repoName” release = “v2.2.0” zip_url = “api.github.com/repos/repoOnwer/repoName/zipball/v2.2.0” dest = “/sandbox/liveserver/customerName/software/repoOnwer/repoName/releases/v2.2.0”
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/deployman/app/install.rb', line 34 def self.install (owner, software, release, zip_url, dest, auth = false) # check if release already installed if !File.directory?(dest) zip_path = DL_DIR << owner << "-" << software << "-" << release << ".zip" begin # download zip file print "> Downloading..." Deployman::Component::Downloader.download_file(zip_url, zip_path, auth) puts "done!" # unzip zip file print "> Unzipping..." Deployman::Extractor::Zip.extract_file(zip_path, dest) puts "done!" # create configuration file print "> Creating Configfile..." create_configfile(owner, software, release, zip_url, dest) puts "done!" # createfiles from api print "> Creating Files from API..." createfiles_from_api(dest) puts "done!" # run deploy.rb print "> Deploying..." deployrb(dest) puts "done!" # create postsetup.json file print "> Creating Postsetupfile..." Deployman::App::Postsetup.createPostsetupFile dest puts "done!" rescue Exception => e warn "ERROR: #{e.message}" raise "Installation failed!" end else puts "> Release already installed!" end end |
.run(options) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/deployman/app/install.rb', line 9 def self.run () = if [:install] puts "> Installation started!" install([:install][0],[:install][1],[:install][2],[:install][3],[:install][4],[:auth]) puts "> Installation finished!" elsif [:uninstall] puts "> Uninstall started!" uninstall([:uninstall]) puts "> Uninstall finished!" else puts "Unknown command. Type --help for more information!", true end end |
.uninstall(release_path) ⇒ Object
UNINSTALL release_path = “/sandbox/liveserver/customerName/software/repoOnwer/repoName/releases/v2.2.0”
86 87 88 |
# File 'lib/deployman/app/install.rb', line 86 def self.uninstall (release_path) FileUtils.rm_rf(release_path) end |