test_dummy.rb
2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
48
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
require 'SystemDataBackend'
require 'SystemDataBackendLdap'
ldap = SystemDataBackendLdap.new(
'host.one.virtual',
389,
'dc=weird-web-workers,dc=org'
)
backend = SystemDataBackend.new(ldap)
backend.users.each do |user|
puts 'user: '+user.name+','+user.uid+','+user.gid+','+user.home
end
puts
backend.groups.each do |group|
members = backend.usersInGroup(group)
puts 'group: '+group.name+','+group.gid
puts ' members:'
group.members.each do |name|
print ' ' + name + ': '
print members[name].uid + ', ' + members[name].home if members[name]
puts
end
puts
end
backend.sites.each do |site|
puts 'site: ' + site.name
puts ' MailAliasRoles:'
backend.mailAliasRolesBySite(site).each{|account| puts ' ' + account.mail}
puts
puts ' MailAliasPeople:'
backend.mailAliasPeopleBySite(site).each{|account| puts ' ' + account.mail}
puts
puts ' MailAccounts:'
backend.mailAccountsBySite(site).each{|account| puts ' ' + account.mail}
puts
end
backend.mailAliasRoles.each do |mailAlias|
puts 'mailAliasRole: '+mailAlias.mail.inspect+','+mailAlias.maildrop.inspect
end
puts
backend.mailAliasPeople.each do |mailAlias|
puts 'mailAliasPerson: '+mailAlias.mail.inspect+','+mailAlias.maildrop.inspect
end
puts
backend.mailAccounts.each do |mailAccount|
puts 'mailAccount: '+mailAccount.mail.inspect+','+mailAccount.mailbox.inspect
end
puts
georg = backend.userByName('georg')
georg.save
puts
georg.uid = 1001
georg.save
puts
wheel = backend.groupByName('wheel')
wheel.save
puts
wheel.gid = 100
wheel.save
puts
site = backend.siteByName('kommandozeilenchef.de')
site.save
puts
site.name = 'wumbaba.de'
site.save
puts
mail = MailAliasRole.new({
:backend => ldap,
:mail => 'newrole@kommandozeilenchef.de',
:maildrop => 'newrole',
:user => 'newrole'
})
mail.save
puts
mail = MailAliasPerson.new({
:backend => ldap,
:mail => 'ohotte@kommandozeilenchef.de',
:maildrop => 'ohotte',
:name => 'Onkel Hotte',
:surname => 'Hotte'
})
mail.save
puts
mail = MailAccount.new({
:backend => ldap,
:mail => 'foobar@kommandozeilenchef.de',
:mailbox => 'kommandozeilenchef.de/foobar',
:home => '/var/spool/vmail/domains'
})
mail.save
puts
puts '====================================='
# -o vsz/vsize
puts 'Memory useage: ' + `ps -o rss= -p #{Process.pid}`