blob: 8907493da176c6b954abfaea64bcde15af4b8fa0 (
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
<?php
require_once('config.inc');
require_once('globals.inc');
require_once('service-utils.inc');
function openntpd_install() {
global $g;
$config_file = $g['varetc_path'] . '/openntpd.conf';
$rcfile = array();
$rcfile['file'] = 'openntpd.sh';
$rcfile['start'] = <<<EOD
if [ -f $config_file ]; then
ntpd -f $config_file
fi
EOD;
$rcfile['stop'] = "killall ntpd";
write_rcfile($rcfile);
}
function openntpd_resync() {
global $g, $config;
$settings = $config['installedpackages']['openntpd']['config'][0];
$config_file = $g['varetc_path'] . '/openntpd.conf';
if ($settings['enable'] == 'on') {
$conf = '';
$ifaces = explode(',', $settings['interface']);
$ips = array_map('get_interface_ip', $ifaces);
foreach ($ips as $ip)
$conf .= "listen on $ip\n";
$servers = explode(',', $config['system']['timeservers']);
foreach ($servers as $server)
$conf .= "servers $server\n";
@file_put_contents($config_file, $conf);
}
else {
if (file_exists($config_file))
unlink($config_file);
}
restart_service('openntpd');
}
|