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)


171
172
173
174
175
# File 'lib/libcfruby/cfrubyscript.rb', line 171

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)


162
163
164
165
166
# File 'lib/libcfruby/cfrubyscript.rb', line 162

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)


153
154
155
156
157
# File 'lib/libcfruby/cfrubyscript.rb', line 153

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')


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

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()


115
116
117
118
119
# File 'lib/libcfruby/cfrubyscript.rb', line 115

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()


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

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()


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

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