Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/libcfruby/cfrubyscript.rb

Overview

Including cfrubyscript adds a number of new helper methods to Array that are useful in cutting down the verbosity of system administration scripts.

Direct Known Subclasses

Cfruby::Cfp_Class

Instance Method Summary collapse

Instance Method Details

#chmod(mode, options = {}) ⇒ Object

Calls Cfruby::FileOps.chmod on each member, allowing for: [‘/usr/local/etc/exim’, ‘/var/service’].chown_mod(‘u=rwX,go-rwx’, :recursive => true)



192
193
194
195
196
# File 'lib/libcfruby/cfrubyscript.rb', line 192

def chmod(mode, options = {})
	self.each() { |filename|
		Cfruby::FileOps.chmod(filename, mode, options)
	}
end

#chown(owner = Process::Sys.geteuid(), group = Process::Sys.getegid(), options = {}) ⇒ Object

Calls Cfruby::FileOps.chown on each member, allowing for: [‘/usr/local/etc/exim’, ‘/var/service’].chown_mod(‘root’, ‘wheel’, :recursive => true)



183
184
185
186
187
# File 'lib/libcfruby/cfrubyscript.rb', line 183

def chown(owner = Process::Sys.geteuid(), group = Process::Sys.getegid(), options = {})
	self.each() { |filename|
		Cfruby::FileOps.chown(filename, owner, group, options)
	}
end

#chown_mod(owner, group, mode, options = {}) ⇒ Object

Calls Cfruby::FileOps.chown_mod on each member, allowing for: [‘/usr/local/etc/exim’, ‘/var/service’].chown_mod(‘root’, ‘wheel’, ‘u=rwX,go-rwx’, :recursive => true)



174
175
176
177
178
# File 'lib/libcfruby/cfrubyscript.rb', line 174

def chown_mod(owner, group, mode, options = {})
	self.each() { |filename|
		Cfruby::FileOps.chown_mod(filename, owner, group, mode, options)
	}
end

#create(owner = Process::Sys.geteuid(), group = Process::Sys.getegid(), mode = 0600) ⇒ Object

Calls Cfruby::FileOps.create on each member, allowing for: [‘/etc/rc.conf’, ‘/etc/resolv.conf’].create(‘root’, ‘wheel’)



165
166
167
168
169
# File 'lib/libcfruby/cfrubyscript.rb', line 165

def create(owner = Process::Sys.geteuid(), group = Process::Sys.getegid(), mode = 0600)
	self.each() { |filename|
		Cfruby::FileOps.create(filename, owner, group, mode)
	}
end

#execObject

Calls Cfruby::Exec.exec() on each member, allowing for: [‘/usr/local/bin/myprogram’, ‘/usr/local/bin/myotherprogram’].exec()



124
125
126
127
128
# File 'lib/libcfruby/cfrubyscript.rb', line 124

def exec()
	self.each() { |command|
		Cfruby::Exec.exec(command)
	}
end

#installObject

Calls Cfruby::Packages::PackageManager.install() on each member, allowing for: [‘apache’, ‘php4’, ‘eruby’].install()



132
133
134
135
136
137
138
139
# File 'lib/libcfruby/cfrubyscript.rb', line 132

def install()
	os = Cfruby::OS::OSFactory.new.get_os()
	pkg_manager = os.get_package_manager()

	self.each() { |pkgname|
		pkg_manager.install(pkgname)
	}
end

#mkdir(options = {}) ⇒ Object

Calls Cfruby::FileOps.mkdir on each member, allowing for: [‘/var/service’, ‘/etc/scripts’].mkdir()



156
157
158
159
160
# File 'lib/libcfruby/cfrubyscript.rb', line 156

def mkdir(options = {})
	self.each() { |filename|
		Cfruby::FileOps.mkdir(filename, options)
	}
end

#uninstallObject

Calls Cfruby::Packages::PackageManager.uninstall() on each member, allowing for: [‘apache’, ‘php4’, ‘eruby’].uninstall()



144
145
146
147
148
149
150
151
# File 'lib/libcfruby/cfrubyscript.rb', line 144

def uninstall()
	os = Cfruby::OS::OSFactory.new.get_os()
	pkg_manager = os.get_package_manager()

	self.each() { |pkgname|
		pkg_manager.uninstall(pkgname)
	}
end