Module: Comodule::Deployment::Helper::ShellCommand
- Defined in:
- lib/comodule/deployment/helper/shell_command.rb
Instance Method Summary collapse
- #chown ⇒ Object
- #command_or_dummy(cmd) ⇒ Object
- #crontab ⇒ Object
- #dummy(method_name, *args) ⇒ Object
- #shell_script ⇒ Object
Instance Method Details
#chown ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/comodule/deployment/helper/shell_command.rb', line 15 def chown return unless config.chown [config.chown].flatten.each do |arg| command_or_dummy "chown #{arg}" end end |
#command_or_dummy(cmd) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/comodule/deployment/helper/shell_command.rb', line 3 def command_or_dummy(cmd) if deployment? `#{cmd}` else dummy :`, cmd end end |
#crontab ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/comodule/deployment/helper/shell_command.rb', line 23 def crontab count = 0 paths = Dir.glob(File.join(common_crontab_dir, '**', '*')) paths += Dir.glob(File.join(crontab_dir, '**', '*')) paths += Dir.glob(File.join(secret_crontab_dir, '**', '*')) rm_rf tmp_crontab_dir be_dir tmp_crontab_dir paths.each do |path| next unless File.file?(path) path = render_in_dir(path, tmp_crontab_dir) cmd = "crontab #{path}" puts "set crontab:\n #{cmd}" command_or_dummy cmd count += 1 end count end |
#dummy(method_name, *args) ⇒ Object
11 12 13 |
# File 'lib/comodule/deployment/helper/shell_command.rb', line 11 def dummy(method_name, *args) puts "execute dummy method: #{method_name}, args: #{args}" end |
#shell_script ⇒ Object
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 |
# File 'lib/comodule/deployment/helper/shell_command.rb', line 49 def shell_script count = 0 paths = Dir.glob(File.join(common_shell_script_dir, '**', '*')) paths += Dir.glob(File.join(shell_script_dir, '**', '*')) paths += Dir.glob(File.join(secret_shell_script_dir, '**', '*')) shell_path = config.shell || '/bin/bash' rm_rf tmp_shell_script_dir be_dir tmp_shell_script_dir paths.each do |path| next unless File.file?(path) path = render_in_dir(path, tmp_shell_script_dir) cmd = "#{shell_path} #{path}" puts "execute shell script:\n #{cmd}" command_or_dummy "#{shell_path} #{path}" count += 1 end count end |