[debian-edu-commits] r81286 - in branches/wheezy/debian-edu-config: debian ldap-tools
pere at alioth.debian.org
pere at alioth.debian.org
Tue Jul 2 07:33:35 UTC 2013
Author: pere
Date: 2013-07-02 07:33:35 +0000 (Tue, 02 Jul 2013)
New Revision: 81286
Modified:
branches/wheezy/debian-edu-config/debian/changelog
branches/wheezy/debian-edu-config/ldap-tools/sitesummary2ldapdhcp
Log:
Clean up ldap-tools/sitesummary2ldapdhcp a bit, avoid some code
duplication and make sure 'ntp' is used as the DNS name for the
local NTP server.
Modified: branches/wheezy/debian-edu-config/debian/changelog
===================================================================
--- branches/wheezy/debian-edu-config/debian/changelog 2013-07-02 07:16:07 UTC (rev 81285)
+++ branches/wheezy/debian-edu-config/debian/changelog 2013-07-02 07:33:35 UTC (rev 81286)
@@ -16,6 +16,9 @@
* Adjust cfengine setup to do a 'files' pass at the end too, to make
sure file permissions are correct when cfengine exits. This
fixes the file permissions of /etc/rsyslog.d/debian-edu-client.conf.
+ * Clean up ldap-tools/sitesummary2ldapdhcp a bit, avoid some code
+ duplication and make sure 'ntp' is used as the DNS name for the
+ local NTP server.
-- Wolfgang Schweer <wschweer at arcor.de> Mon, 01 Jul 2013 19:04:57 +0200
Modified: branches/wheezy/debian-edu-config/ldap-tools/sitesummary2ldapdhcp
===================================================================
--- branches/wheezy/debian-edu-config/ldap-tools/sitesummary2ldapdhcp 2013-07-02 07:16:07 UTC (rev 81285)
+++ branches/wheezy/debian-edu-config/ldap-tools/sitesummary2ldapdhcp 2013-07-02 07:33:35 UTC (rev 81286)
@@ -40,12 +40,13 @@
-a Add new hosts as well as update existing hosts.
-d Enable debug output.
-i ID Handle host with the given sitesummary ID only.
- -u userfiler Filter used to find LDAP user used to update LDAP.
- -t TYPE Specify type of system(s) to add. TYPE can be: servers, workstations, terminals \
- or printers. If -t is omitted, added systems will be of type netdevices.
+ -u userfilter Filter used to find LDAP user used to update LDAP.
+ -t TYPE Specify type of system(s) to add. TYPE can be: servers,
+ workstations, terminals or printers. If -t is omitted,
+ added systems will be of type netdevices.
EOF
-exit $retval;
+ exit $retval;
}
my $retval = 0;
@@ -139,6 +140,7 @@
my ($hostname, $dnsdomain) = split(/\./, $fqdn, 2);
my $cn = "cn=$hostname,$systembase";
+
my $mesg = $ldap->search(
base => $base,
filter => "(&(|(objectClass=goServer)(objectClass=device)(objectClass=GOhard)(objectClass=gotoWorkstation)(objectClass=gotoTerminal))(|(cn=$hostname)(macAddress=$mac)))",
@@ -147,105 +149,81 @@
print "info: search found " . $mesg->count . " objects\n" if $debug;
if (0 == $mesg->count) {
- if ($opts{t}) {
- # Create entry of type $type
- my $gotoMode = "active";
- my $gotoSwapServer = "!";
- my $gotoNtpServer = "tjener";
- my $ghCpuType = "-";
- my $ghMemSize = "-";
- my $ghUsbSupport = "-";
- my $ghGfxAdapter = "-";
- my $ghSoundAdapter = "-";
- my $gotoLastUser = "-";
- my $printerUri = "DUMMY, please change.";
- if ($opts{t} eq 'servers') {
- my $attr = [
- 'objectClass' => ['top', 'GOhard', 'goServer'],
- 'cn' => $hostname,
- 'macAddress' => $mac,
- 'ipHostNumber' => $ipaddr,
- 'gotoMode' => $gotoMode,
+ # Create entry of type $type
+ my $gotoMode = "active";
+ my $gotoSwapServer = "!";
+ my $gotoNtpServer = "ntp";
+ my $ghCpuType = "-";
+ my $ghMemSize = "-";
+ my $ghUsbSupport = "-";
+ my $ghGfxAdapter = "-";
+ my $ghSoundAdapter = "-";
+ my $gotoLastUser = "-";
+ my $attr;
+ if ($opts{t} eq 'servers') {
+ $attr = [
+ 'objectClass' => ['top', 'GOhard', 'goServer'],
+ 'cn' => $hostname,
+ 'macAddress' => $mac,
+ 'ipHostNumber' => $ipaddr,
+ 'gotoMode' => $gotoMode,
];
-
- my $result = $ldap->add($cn, attr => $attr);
- if ($result->code) {
- my $err = $result->error;
- print STDERR "error: Unable to add LDAP object $cn - $err\n";
-
- }
- } elsif ($opts{t} eq 'workstations') {
- my $attr = [
- 'objectClass' => ['top', 'gotoWorkstation', 'GOhard'],
- 'cn' => $hostname,
- 'macAddress' => $mac,
- 'ipHostNumber' => $ipaddr,
- 'gotoMode' => $gotoMode,
- 'gotoNtpServer' => $gotoNtpServer,
- 'ghCpuType' => $ghCpuType,
- 'ghMemSize' => $ghMemSize,
- 'ghUsbSupport' => $ghUsbSupport,
- 'ghGfxAdapter' => $ghGfxAdapter,
- 'ghSoundAdapter' => $ghSoundAdapter,
- 'gotoLastUser' => $gotoLastUser,
+ } elsif ($opts{t} eq 'workstations') {
+ $attr = [
+ 'objectClass' => ['top', 'gotoWorkstation', 'GOhard'],
+ 'cn' => $hostname,
+ 'macAddress' => $mac,
+ 'ipHostNumber' => $ipaddr,
+ 'gotoMode' => $gotoMode,
+ 'gotoNtpServer' => $gotoNtpServer,
+ 'ghCpuType' => $ghCpuType,
+ 'ghMemSize' => $ghMemSize,
+ 'ghUsbSupport' => $ghUsbSupport,
+ 'ghGfxAdapter' => $ghGfxAdapter,
+ 'ghSoundAdapter' => $ghSoundAdapter,
+ 'gotoLastUser' => $gotoLastUser,
];
-
- my $result = $ldap->add($cn, attr => $attr);
- if ($result->code) {
- my $err = $result->error;
- print STDERR "error: Unable to add LDAP object $cn - $err\n";
-
- }
- } elsif ($opts{t} eq 'terminals') {
- my $attr = [
- 'objectClass' => ['top', 'gotoTerminal', 'GOhard'],
- 'cn' => $hostname,
- 'macAddress' => $mac,
- 'ipHostNumber' => $ipaddr,
- 'gotoMode' => $gotoMode,
- 'gotoNtpServer' => $gotoNtpServer,
- 'ghCpuType' => $ghCpuType,
- 'ghMemSize' => $ghMemSize,
- 'ghUsbSupport' => $ghUsbSupport,
- 'ghGfxAdapter' => $ghGfxAdapter,
- 'ghSoundAdapter' => $ghSoundAdapter,
- 'gotoLastUser' => $gotoLastUser,
- 'gotoSwapServer' => $gotoSwapServer,
+ } elsif ($opts{t} eq 'terminals') {
+ $attr = [
+ 'objectClass' => ['top', 'gotoTerminal', 'GOhard'],
+ 'cn' => $hostname,
+ 'macAddress' => $mac,
+ 'ipHostNumber' => $ipaddr,
+ 'gotoMode' => $gotoMode,
+ 'gotoNtpServer' => $gotoNtpServer,
+ 'ghCpuType' => $ghCpuType,
+ 'ghMemSize' => $ghMemSize,
+ 'ghUsbSupport' => $ghUsbSupport,
+ 'ghGfxAdapter' => $ghGfxAdapter,
+ 'ghSoundAdapter' => $ghSoundAdapter,
+ 'gotoLastUser' => $gotoLastUser,
+ 'gotoSwapServer' => $gotoSwapServer,
];
-
- my $result = $ldap->add($cn, attr => $attr);
- if ($result->code) {
- my $err = $result->error;
- print STDERR "error: Unable to add LDAP object $cn - $err\n";
- }
- } elsif ($opts{t} eq 'printers') {
- my $attr = [
- 'objectClass' => ['top', 'gotoPrinter'],
- 'cn' => $hostname,
- 'macAddress' => $mac,
- 'ipHostNumber' => $ipaddr,
- 'labeledURI' => $printerUri,
+ } elsif ($opts{t} eq 'printers') {
+ my $printerUri = "DUMMY, please change.";
+ $attr = [
+ 'objectClass' => ['top', 'gotoPrinter'],
+ 'cn' => $hostname,
+ 'macAddress' => $mac,
+ 'ipHostNumber' => $ipaddr,
+ 'labeledURI' => $printerUri,
];
-
- my $result = $ldap->add($cn, attr => $attr);
- if ($result->code) {
- my $err = $result->error;
- print STDERR "error: Unable to add LDAP object $cn - $err\n";
- }
- }
- } else {
- my $attr = [
+ } elsif ($opts{t} eq 'netdevices') {
+ $attr = [
'objectClass' => 'dhcpHost',
'cn' => $hostname,
'dhcpHWAddress' => "ethernet $mac",
'dhcpStatements' => "fixed-address $fqdn"
- ];
-
+ ];
+ }
+ if ($attr) {
my $result = $ldap->add($cn, attr => $attr);
if ($result->code) {
my $err = $result->error;
print STDERR "error: Unable to add LDAP object $cn - $err\n";
}
+ } else {
+ print STDERR "error: Unknown type $type, not adding objects\n";
}
} elsif (1 == $mesg->count) {
# Update
More information about the debian-edu-commits
mailing list