1 |
diff -up e-smith-samba-2.2.0/createlinks.remove-domains e-smith-samba-2.2.0/createlinks |
2 |
--- e-smith-samba-2.2.0/createlinks.remove-domains 2010-10-28 08:45:52.000000000 -0600 |
3 |
+++ e-smith-samba-2.2.0/createlinks 2010-10-28 08:45:17.000000000 -0600 |
4 |
@@ -83,6 +83,7 @@ |
5 |
|
6 |
$event = "workgroup-update"; |
7 |
event_link("update-domain-group-maps", $event, "56"); |
8 |
+event_link("cleanup-domains", $event, "65"); |
9 |
safe_symlink("sigterm", "root/etc/e-smith/events/$event/services2adjust/dhcpd"); |
10 |
safe_symlink("sigterm", "root/etc/e-smith/events/$event/services2adjust/smbd"); |
11 |
safe_symlink("sigterm", "root/etc/e-smith/events/$event/services2adjust/nmbd"); |
12 |
diff -up e-smith-samba-2.2.0/root/etc/e-smith/events/actions/cleanup-domains.remove-domains e-smith-samba-2.2.0/root/etc/e-smith/events/actions/cleanup-domains |
13 |
--- e-smith-samba-2.2.0/root/etc/e-smith/events/actions/cleanup-domains.remove-domains 2010-11-02 09:51:35.000000000 -0600 |
14 |
+++ e-smith-samba-2.2.0/root/etc/e-smith/events/actions/cleanup-domains 2010-11-02 10:07:43.000000000 -0600 |
15 |
@@ -0,0 +1,56 @@ |
16 |
+#!/usr/bin/perl -w |
17 |
+ |
18 |
+package esmith; |
19 |
+ |
20 |
+use strict; |
21 |
+use Errno; |
22 |
+use esmith::ConfigDB; |
23 |
+use esmith::util; |
24 |
+use Net::LDAP; |
25 |
+ |
26 |
+my $c = esmith::ConfigDB->open_ro; |
27 |
+ |
28 |
+# Don't attempt to update ldap unles master |
29 |
+exit(0) unless ($c->get('ldap')->prop('Authentication') || 'disabled') eq 'enabled'; |
30 |
+ |
31 |
+my $l = $c->get('ldap'); |
32 |
+my $status = $l->prop('status') || "disabled"; |
33 |
+unless ($status eq "enabled" ) |
34 |
+{ |
35 |
+ warn "Not running action script $0, LDAP service not enabled!\n"; |
36 |
+ exit(0); |
37 |
+} |
38 |
+ |
39 |
+my $domain = $c->get('DomainName') |
40 |
+|| die("Couldn't determine domain name"); |
41 |
+$domain = $domain->value; |
42 |
+ |
43 |
+my $base = esmith::util::ldapBase ($domain); |
44 |
+my $pw = esmith::util::LdapPassword(); |
45 |
+ |
46 |
+my $ldap = Net::LDAP->new('localhost') |
47 |
+ or die "$@"; |
48 |
+ |
49 |
+$ldap->bind( |
50 |
+ dn => "cn=root,$base", |
51 |
+ password => $pw |
52 |
+); |
53 |
+ |
54 |
+my $smb = $c->get('smb'); |
55 |
+my $domName = $smb->prop('Workgroup') || 'mitel-network'; |
56 |
+if ( ($smb->prop('ServerRole') || 'WS') eq 'WS' ) |
57 |
+{ |
58 |
+ $domName = $smb->prop('ServerName') || 'e-smith-server'; |
59 |
+} |
60 |
+ |
61 |
+my $result = $ldap->search( base => $base, |
62 |
+ filter => "(&(objectClass=sambaDomain)(!(sambaDomainName=$domName)))", |
63 |
+ scope => 'one' |
64 |
+); |
65 |
+die "failed looking up sambaDomainName entry: ", $result->error if $result->code; |
66 |
+ |
67 |
+foreach ($result->entries) |
68 |
+{ |
69 |
+ $_->delete; |
70 |
+ $_->update($ldap); |
71 |
+} |