Module: Machines::Commands::Configuration
- Included in:
- Machines::Core
- Defined in:
- lib/machines/commands/configuration.rb
Instance Method Summary collapse
-
#add(options) ⇒ Object
Add an existing user to a secondary group.
-
#add_user(login, options = {}) ⇒ Object
Add a new user (uses the lowlevel useradd so doesn't set a password unless specified).
-
#configure(options) ⇒ Object
Sets gconf key value pairs.
-
#del_user(login) ⇒ Object
Removes a user, home and any other related files.
Instance Method Details
#add(options) ⇒ Object
Add an existing user to a secondary group
23 24 25 26 |
# File 'lib/machines/commands/configuration.rb', line 23 def add , [:user, :to] Command.new("usermod -a -G #{[:to]} #{[:user]}", check_command("groups #{[:user]}", [:to])) end |
#add_user(login, options = {}) ⇒ Object
Add a new user (uses the lowlevel useradd so doesn't set a password unless specified)
10 11 12 13 14 15 16 17 |
# File 'lib/machines/commands/configuration.rb', line 10 def add_user login, = {} password = "-p #{`openssl passwd #{[:password]}`.gsub("\n", '')} " if [:password] admin = "-G admin " if [:admin] Command.new( "useradd -s /bin/bash -d /home/#{login} -m #{password}#{admin}#{login}", check_dir("/home/#{login}") ) end |
#configure(options) ⇒ Object
Sets gconf key value pairs
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/machines/commands/configuration.rb', line 30 def configure .map do |key, value| types = {String => 'string', Fixnum => 'int', TrueClass => 'bool', FalseClass => 'bool', Float => 'float', Array => 'list --list-type=string'} type = types[value.class] raise 'Invalid type for configure' unless type value = value.to_json if value.is_a?(Array) value = %("#{value}") if type == 'string' check = "gconftool-2 --get \"#{key}\" | grep #{value} #{echo_result}" Command.new("gconftool-2 --set \"#{key}\" --type #{type} #{value}", check) end end |