summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8f9b4ff)
raw | patch | inline | side by side (parent: 8f9b4ff)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 19 Aug 2008 13:40:46 +0000 (13:40 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 19 Aug 2008 13:40:46 +0000 (13:40 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12246 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/client/events/corefunctions.pm | patch | blob | history | |
gosa-si/modules/ClientPackages.pm | patch | blob | history | |
gosa-si/tests/client.php | patch | blob | history |
index 5ccf161195c2c2a0f9dc17d059d1eba3f0c45a31..4f5bd3629eeaec1b771b3a1cb2b5c1e2272b3a94 100644 (file)
my @events = (
"get_events",
"registered",
+ "new_ntp_config",
"new_ldap_config",
"new_key",
"generate_hw_digest", # no implementations
my ($ldap_enabled, $offline_enabled, $ldap_config, $pam_config, $nss_config, $fai_logpath);
+my $chrony_file = "/etc/chrony/chrony.conf";
my %cfg_defaults = (
"client" => {
return;
}
+## @method new_ntp_config
+# Updates the server options in /etc/chrony/chrony.conf and restarts the chrony service
+# @param msg - STRING - xml message with tag server
+# @param msg_hash - HASHREF - message information parsed into a hash
+sub new_ntp_config {
+ my ($msg, $msg_hash) = @_ ;
+
+ # Sanity check of incoming message
+ if ((not exists $msg_hash->{'server'}) || (not @{$msg_hash->{'server'}} >= 1) ) {
+ &main::daemon_log("ERROR: 'new_ntp_config'-message does not contain a ntp server: $msg", 1);
+ return;
+ }
+
+ # Fetch the new ntp server from incoming message
+ my @ntp_servers = $msg_hash->{'server'};
+ my $ntp_servers_string = "server\t".join("\nserver\t", @ntp_servers)."\n";
+ my $found_server_flag = 0;
+
+ # Substitute existing server with new ntp server
+ open (FILE, "+<$chrony_file");
+ my @file = <FILE>;
+ foreach my $line (@file) {
+ if ($line =~ /^server /) {
+ if ($found_server_flag) {
+ $line =~ s/^server [\s\S]+$//;
+ } else {
+ $line =~ s/^server [\s\S]+$/$ntp_servers_string/;
+ }
+ $found_server_flag++;
+ }
+ }
+
+ # Append new server if no old server configuration found
+ if (not $found_server_flag) {
+ push(@file, "\n# ntp server configuration written by GOsa-si\n");
+ push(@file, $ntp_servers_string);
+ }
+
+ # Write changes to file and close it
+ print FILE join("", @file);
+ close FILE;
+ &main::daemon_log("INFO: wrote new configuration file: $chrony_file", 5);
+
+ # Restart chrony deamon
+ my $res = qx(/etc/init.d/chrony force-reload);
+ &main::daemon_log("INFO: restart chrony daemon: $res", 5);
+
+ return;
+}
+
sub new_ldap_config {
my ($msg, $msg_hash) = @_ ;
index 911e12121ed876d6a161fa4d8cace01bdf7dec53..d4ec76321c87bb9fb53b66929b8b38028194d559 100644 (file)
# Sanity check
if ($ldap_res->count != 1) {
- &main::daemon_log("$session_id ERROR: client with mac address $address not found/unique/active - not sending ldap config".
+ &main::daemon_log("$session_id ERROR: client with mac address $address not found/unique/active - not sending ntp config".
"\n\tbase: $ldap_base".
"\n\tscope: sub".
"\n\tattrs: gotoNtpServer".
# Sanity check
if ($ldap_res->count != 1) {
- &main::daemon_log("$session_id ERROR: client with mac address $address not found/unique/active - not sending ldap config".
+ &main::daemon_log("$session_id ERROR: client with mac address $address not found/unique/active - not sending ntp config".
"\n\tbase: $ldap_base".
"\n\tscope: sub".
"\n\tattrs: gotoNtpServer".
}
# Add each ntp server to 'ntp_config' message
- my $ntp_msg_hash = &create_xml_hash("ntp_config", $server_address, $address);
+ my $ntp_msg_hash = &create_xml_hash("new_ntp_config", $server_address, $address);
foreach my $ntp_server (@ntp_servers) {
&add_content2xml_hash($ntp_msg_hash, "server", $ntp_server);
}
index 772cc39f682456b75c2e11681e5d57c5b52088a7..158da47acef74270cf4e494e3b37a43f05dca578 100755 (executable)
--- a/gosa-si/tests/client.php
+++ b/gosa-si/tests/client.php
##############################
# NTP reload
- $data = "<xml> <header>gosa_trigger_reload_ntp_config</header> <source>GOSA</source> <target>GOSA</target> <macaddress>00:11:25:4B:8C:E5</macaddress> </xml>";
+ #$data = "<xml> <header>gosa_trigger_reload_ntp_config</header> <source>GOSA</source> <target>GOSA</target> <macaddress>00:11:25:4B:8C:E5</macaddress> </xml>";
+ $data = "<xml> <header>gosa_trigger_reload_ntp_config</header> <source>GOSA</source> <target>GOSA</target> <macaddress>00:01:6c:9d:b9:fa</macaddress> </xml>";
$sock->write($data);
$answer = "nothing";