Module: Linebook::Shell
- Defined in:
- lib/linebook/shell.rb,
lib/linebook/shell/bash.rb
Defined Under Namespace
Modules: Bash
Class Method Summary collapse
Instance Method Summary collapse
-
#_directory(*args, &block) ⇒ Object
:nodoc:.
-
#_file(*args, &block) ⇒ Object
:nodoc:.
-
#_group(*args, &block) ⇒ Object
:nodoc:.
-
#_package(*args, &block) ⇒ Object
:nodoc:.
-
#_recipe(*args, &block) ⇒ Object
:nodoc:.
-
#_template(*args, &block) ⇒ Object
:nodoc:.
-
#_user(*args, &block) ⇒ Object
:nodoc:.
-
#_userdel(*args, &block) ⇒ Object
:nodoc:.
-
#_usermod(*args, &block) ⇒ Object
:nodoc:.
- #directory(target, options = {}) ⇒ Object
-
#file(file_name, target, options = {}) ⇒ Object
Installs a file from the package.
- #group(name, options = {}) ⇒ Object
- #package(name, version = nil) ⇒ Object
- #recipe(recipe_name) ⇒ Object
-
#template(template_name, target, options = {}) ⇒ Object
Installs a template from the package.
- #user(name, options = {}) ⇒ Object
- #userdel(name, options = {}) ⇒ Object
- #usermod(name, options = {}) ⇒ Object
Class Method Details
.extended(base) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/linebook/shell.rb', line 5 def self.extended(base) base.attributes 'linebook/shell' if os = base.attrs['linebook']['os'] base.helpers os end if shell = base.attrs['linebook']['shell'] base.helpers shell end super end |
Instance Method Details
#_directory(*args, &block) ⇒ Object
:nodoc:
28 29 30 31 32 |
# File 'lib/linebook/shell.rb', line 28 def _directory(*args, &block) # :nodoc: str = capture_str { directory(*args, &block) } str.strip! str end |
#_file(*args, &block) ⇒ Object
:nodoc:
42 43 44 45 46 |
# File 'lib/linebook/shell.rb', line 42 def _file(*args, &block) # :nodoc: str = capture_str { file(*args, &block) } str.strip! str end |
#_group(*args, &block) ⇒ Object
:nodoc:
55 56 57 58 59 |
# File 'lib/linebook/shell.rb', line 55 def _group(*args, &block) # :nodoc: str = capture_str { group(*args, &block) } str.strip! str end |
#_package(*args, &block) ⇒ Object
:nodoc:
66 67 68 69 70 |
# File 'lib/linebook/shell.rb', line 66 def _package(*args, &block) # :nodoc: str = capture_str { package(*args, &block) } str.strip! str end |
#_recipe(*args, &block) ⇒ Object
:nodoc:
91 92 93 94 95 |
# File 'lib/linebook/shell.rb', line 91 def _recipe(*args, &block) # :nodoc: str = capture_str { recipe(*args, &block) } str.strip! str end |
#_template(*args, &block) ⇒ Object
:nodoc:
106 107 108 109 110 |
# File 'lib/linebook/shell.rb', line 106 def _template(*args, &block) # :nodoc: str = capture_str { template(*args, &block) } str.strip! str end |
#_user(*args, &block) ⇒ Object
:nodoc:
119 120 121 122 123 |
# File 'lib/linebook/shell.rb', line 119 def _user(*args, &block) # :nodoc: str = capture_str { user(*args, &block) } str.strip! str end |
#_userdel(*args, &block) ⇒ Object
:nodoc:
130 131 132 133 134 |
# File 'lib/linebook/shell.rb', line 130 def _userdel(*args, &block) # :nodoc: str = capture_str { userdel(*args, &block) } str.strip! str end |
#_usermod(*args, &block) ⇒ Object
:nodoc:
141 142 143 144 145 |
# File 'lib/linebook/shell.rb', line 141 def _usermod(*args, &block) # :nodoc: str = capture_str { usermod(*args, &block) } str.strip! str end |
#directory(target, options = {}) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/linebook/shell.rb', line 19 def directory(target, ={}) unless_ _directory?(target) do mkdir '-p', target end chmod [:mode] || 0755, target chown [:owner], [:group], target chain_proxy end |
#file(file_name, target, options = {}) ⇒ Object
Installs a file from the package.
35 36 37 38 39 40 |
# File 'lib/linebook/shell.rb', line 35 def file(file_name, target, ={}) source = file_path(file_name, guess_target_name(target)) = {:D => true}.merge() install(source, target, ) chain_proxy end |
#group(name, options = {}) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/linebook/shell.rb', line 48 def group(name, ={}) unless_ _group?(name) do groupadd name end chain_proxy end |
#package(name, version = nil) ⇒ Object
61 62 63 64 |
# File 'lib/linebook/shell.rb', line 61 def package(name, version=nil) raise NotImplementedError chain_proxy end |
#recipe(recipe_name) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/linebook/shell.rb', line 72 def recipe(recipe_name) target_name = File.join('recipes', recipe_name) recipe_path = _package_.registry.has_key?(target_name) ? target_path(target_name) : self.recipe_path(recipe_name, target_name, 0777) dir = target_path File.join('tmp', recipe_name) unless_ _directory?(dir) do current = target_path('tmp') recipe_name.split('/').each do |segment| current = File.join(current, segment) directory current, :mode => 0770 end writeln "#{quote(recipe_path)} $*" check_status end chain_proxy end |
#template(template_name, target, options = {}) ⇒ Object
Installs a template from the package.
98 99 100 101 102 103 104 |
# File 'lib/linebook/shell.rb', line 98 def template(template_name, target, ={}) locals = .delete(:locals) || {'attrs' => attrs} source = template_path(template_name, guess_target_name(target), 0600, locals) = {:D => true}.merge() install(source, target, ) chain_proxy end |
#user(name, options = {}) ⇒ Object
112 113 114 115 116 117 |
# File 'lib/linebook/shell.rb', line 112 def user(name, ={}) unless_ _user?(name) do useradd name, end chain_proxy end |
#userdel(name, options = {}) ⇒ Object
125 126 127 128 |
# File 'lib/linebook/shell.rb', line 125 def userdel(name, ={}) execute 'userdel', name, chain_proxy end |
#usermod(name, options = {}) ⇒ Object
136 137 138 139 |
# File 'lib/linebook/shell.rb', line 136 def usermod(name, ={}) execute 'usermod', name, chain_proxy end |