blob: 71eddd91da2820a80b1ba8beeb9c7f8b0efac6c8 (
plain)
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
|
#!/usr/bin/ruby
#
# Copyright (c) 2004 Peter Palfrader <peter@palfrader.org>
#
# All rights reserved.
#
require "ldap"
require "getoptlong"
require "myldap"
require "yaml"
@config = YAML::load( File.open( '/etc/noreply/config' ) )
@basedir = @config['module']['mail']['basedir']
ldap = MyLDAP.new(@config, "ldap2mail")
clients = ldap.conn.search2(@config['basedn'], LDAP::LDAP_SCOPE_SUBTREE, 'objectclass=tnClient')
clients.each { |c|
if not File.exists?(@basedir + "/" + c['o'][0])
Dir.mkdir(@basedir + "/" + c['o'][0], 02700 )
File.chown(c['uidNumber'][0].to_i, c['gidNumber'][0].to_i, @basedir + "/" + c['o'][0])
elsif not File.stat( @basedir + "/" + c['o'][0]).directory?
STDERR.puts("Warning: #{@basedir}/#{c['o'][0]} is not a directory.");
end
}
|