Sha256: f678eb0b01521a6993cb129696fb0982b53b4af942a8c404de7beb819c15c357

Contents?: true

Size: 890 Bytes

Versions: 7

Compression:

Stored size: 890 Bytes

Contents

require 'fileutils'
require 'util'
require 'yaml'
require 'thor'
require 'thor/group'

class GenerateBackupScripts < Thor::Group
  include DockerMgr::Util
  include Thor::Actions

  def self.source_root
    File.expand_path('../templates',__dir__)
  end

  argument :app_name,
    :type => :string,
    :desc => 'name of the app'

  def generate_backup_scripts
    app_path = "#{apps_dir}/#{@app_name}"
    hooks = data_services(@app_name)
    hooks << "before_all"
    hooks << "after_all"
    %w(backup restore).each do | hook_type |
      hooks.each do | hook  |
        @service = hook
        template_name = hook == 'before_all' || hook == 'after_all' ? hook : hook_type
        template "#{template_name}.erb","#{app_path}/administration/hooks/#{hook_type}.d/#{hook}"
        FileUtils.chmod 0750,"#{app_path}/administration/hooks/#{hook_type}.d/#{hook}"
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
dockersitter-0.5.0 lib/commands/generate_backup_scripts.rb
dockersitter-0.4.0 lib/commands/generate_backup_scripts.rb
dockersitter-0.3.0 lib/commands/generate_backup_scripts.rb
dockersitter-0.2.2 lib/commands/generate_backup_scripts.rb
dockersitter-0.2.1 lib/commands/generate_backup_scripts.rb
dockersitter-0.2.0 lib/commands/generate_backup_scripts.rb
dockersitter-0.1.0 lib/commands/generate_backup_scripts.rb