diff options
Diffstat (limited to 'src/etc/inc/services.inc')
-rw-r--r-- | src/etc/inc/services.inc | 58 |
1 files changed, 32 insertions, 26 deletions
diff --git a/src/etc/inc/services.inc b/src/etc/inc/services.inc index d13f44a..7dd1739 100644 --- a/src/etc/inc/services.inc +++ b/src/etc/inc/services.inc @@ -391,7 +391,7 @@ function services_dhcpd_configure($family = "all", $blacklist = array()) { global $config, $g; /* configure DHCPD chroot once */ - $fd = fopen("{$g['tmp_path']}/dhcpd.sh","w"); + $fd = fopen("{$g['tmp_path']}/dhcpd.sh", "w"); fwrite($fd, "/bin/mkdir -p {$g['dhcpd_chroot_path']}\n"); fwrite($fd, "/bin/mkdir -p {$g['dhcpd_chroot_path']}/dev\n"); fwrite($fd, "/bin/mkdir -p {$g['dhcpd_chroot_path']}/etc\n"); @@ -406,7 +406,7 @@ function services_dhcpd_configure($family = "all", $blacklist = array()) { fwrite($fd, "/bin/cp -n /usr/local/sbin/dhcpd {$g['dhcpd_chroot_path']}/usr/local/sbin/\n"); fwrite($fd, "/bin/chmod a+rx {$g['dhcpd_chroot_path']}/usr/local/sbin/dhcpd\n"); - $status = `/sbin/mount | /usr/bin/grep -v grep | /usr/bin/grep "{$g['dhcpd_chroot_path']}/dev"`; + $status = `/sbin/mount | /usr/bin/grep -v grep | /usr/bin/grep "{$g['dhcpd_chroot_path']}/dev"`; if (!trim($status)) { fwrite($fd, "/sbin/mount -t devfs devfs {$g['dhcpd_chroot_path']}/dev\n"); } @@ -596,7 +596,7 @@ EOD; $my_port = "519"; $peer_port = "520"; $type = "primary"; - $dhcpdconf_pri = "split 128;\n"; + $dhcpdconf_pri = "split 128;\n"; $dhcpdconf_pri .= " mclt 600;\n"; } @@ -709,16 +709,16 @@ EOPP; $all_mac_strings[] = $dhcpifconf['mac_allow']; $all_mac_strings[] = $dhcpifconf['mac_deny']; if (!empty($all_mac_strings)) { - $all_mac_list = array_unique(explode(',', implode(',', $all_mac_strings))); - foreach ($all_mac_list as $mac) { - if (empty($mac)) { - continue; + $all_mac_list = array_unique(explode(',', implode(',', $all_mac_strings))); + foreach ($all_mac_list as $mac) { + if (empty($mac)) { + continue; + } + $dhcpdconf .= 'class "' . str_replace(':', '', $mac) . '" {' . "\n"; + // Skip the first octet of the MAC address - for media type, typically Ethernet ("01") and match the rest. + $dhcpdconf .= ' match if substring (hardware, 1, ' . (substr_count($mac, ':') + 1) . ') = ' . $mac . ';' . "\n"; + $dhcpdconf .= '}' . "\n"; } - $dhcpdconf .= 'class "' . str_replace(':', '', $mac) . '" {' . "\n"; - // Skip the first octet of the MAC address - for media type, typically Ethernet ("01") and match the rest. - $dhcpdconf .= ' match if substring (hardware, 1, ' . (substr_count($mac, ':') + 1) . ') = ' . $mac . ';' . "\n"; - $dhcpdconf .= '}' . "\n"; - } } $dhcpdconf .= "subnet {$subnet} netmask {$subnetmask} {\n"; @@ -1611,7 +1611,7 @@ function services_dhcrelay_configure() { if (!is_array($srvips)) { log_error("No destination IP has been configured!"); return; - } + } $dhcrelayifs = array_unique($dhcrelayifs); @@ -1621,10 +1621,10 @@ function services_dhcrelay_configure() { return; /* XXX */ } - $cmd = "/usr/local/sbin/dhcrelay -i " . implode(" -i ", $dhcrelayifs); + $cmd = "/usr/local/sbin/dhcrelay -i " . implode(" -i ", $dhcrelayifs); if (isset($dhcrelaycfg['agentoption'])) { - $cmd .= " -a -m replace"; + $cmd .= " -a -m replace"; } $cmd .= " " . implode(" ", $srvips); @@ -1719,8 +1719,8 @@ function services_dyndns_configure_client($conf) { $dnsPort = NULL, $dnsUpdateURL = "{$conf['updateurl']}", $forceUpdate = $conf['force'], - $dnsZoneID=$conf['zoneid'], - $dnsTTL=$conf['ttl'], + $dnsZoneID = $conf['zoneid'], + $dnsTTL = $conf['ttl'], $dnsResultMatch = "{$conf['resultmatch']}", $dnsRequestIf = "{$conf['requestif']}", $dnsID = "{$conf['id']}", @@ -1819,7 +1819,7 @@ function services_dnsmasq_configure() { } /* generate hosts file */ - if (system_hosts_generate()!=0) { + if (system_hosts_generate() != 0) { $return = 1; } @@ -1975,7 +1975,7 @@ function services_dnsmasq_configure() { } if (!platform_booting()) { - if (services_dhcpd_configure()!=0) { + if (services_dhcpd_configure() != 0) { $return = 1; } } @@ -2005,7 +2005,7 @@ function services_unbound_configure() { } /* generate hosts file */ - if (system_hosts_generate()!=0) { + if (system_hosts_generate() != 0) { $return = 1; } @@ -2019,7 +2019,7 @@ function services_unbound_configure() { } if (!platform_booting()) { - if (services_dhcpd_configure()!=0) { + if (services_dhcpd_configure() != 0) { $return = 1; } } @@ -2050,7 +2050,7 @@ function services_snmpd_configure() { /* generate snmpd.conf */ $fd = fopen("{$g['varetc_path']}/snmpd.conf", "w"); if (!$fd) { - printf(gettext("Error: cannot open snmpd.conf in services_snmpd_configure().%s"),"\n"); + printf(gettext("Error: cannot open snmpd.conf in services_snmpd_configure().%s"), "\n"); return 1; } @@ -2496,10 +2496,11 @@ function upnp_start() { } } -function install_cron_job($command, $active=false, $minute="0", $hour="*", $monthday="*", $month="*", $weekday="*", $who="root") { +function install_cron_job($command, $active = false, $minute = "0", $hour = "*", $monthday = "*", $month = "*", $weekday = "*", $who = "root") { global $config, $g; $is_installed = false; + $cron_changed = true; if (!is_array($config['cron'])) { $config['cron'] = array(); @@ -2508,7 +2509,7 @@ function install_cron_job($command, $active=false, $minute="0", $hour="*", $mont $config['cron']['item'] = array(); } - $x=0; + $x = 0; foreach ($config['cron']['item'] as $item) { if (strstr($item['command'], $command)) { $is_installed = true; @@ -2530,8 +2531,13 @@ function install_cron_job($command, $active=false, $minute="0", $hour="*", $mont $config['cron']['item'][] = $cron_item; write_config(sprintf(gettext("Installed cron job for %s"), $command)); } else { - $config['cron']['item'][$x] = $cron_item; - write_config(sprintf(gettext("Updated cron job for %s"), $command)); + if ($config['cron']['item'][$x] == $cron_item) { + $cron_changed = false; + log_error(sprintf(gettext("Checked cron job for %s, no change needed"), $command)); + } else { + $config['cron']['item'][$x] = $cron_item; + write_config(sprintf(gettext("Updated cron job for %s"), $command)); + } } } else { if ($is_installed == true) { |