* syslogd: print messages in the local time zone.
* dhcpd: log to facility "local1". * syslogd: send "local1" messages to /var/log/dhcpd, and "mail" messages to /var/log/mail. svn path=/nixos/trunk/; revision=11780
This commit is contained in:
parent
5d5f48af83
commit
6f64c4ee0d
@ -71,11 +71,12 @@ let
|
|||||||
in pkgs.lib.concatLists ( map nameToJobs (attrNames services)));
|
in pkgs.lib.concatLists ( map nameToJobs (attrNames services)));
|
||||||
|
|
||||||
jobs = map makeJob
|
jobs = map makeJob
|
||||||
( newProposalJobs ++
|
(newProposalJobs ++ [
|
||||||
[
|
|
||||||
# Syslogd.
|
# Syslogd.
|
||||||
(import ../upstart-jobs/syslogd.nix {
|
(import ../upstart-jobs/syslogd.nix {
|
||||||
inherit (pkgs) sysklogd writeText;
|
inherit (pkgs) sysklogd writeText;
|
||||||
|
inherit config;
|
||||||
})
|
})
|
||||||
|
|
||||||
# The udev daemon creates devices nodes and runs programs when
|
# The udev daemon creates devices nodes and runs programs when
|
||||||
|
@ -6,44 +6,45 @@ let
|
|||||||
|
|
||||||
stateDir = "/var/lib/dhcp"; # Don't use /var/state/dhcp; not FHS-compliant.
|
stateDir = "/var/lib/dhcp"; # Don't use /var/state/dhcp; not FHS-compliant.
|
||||||
|
|
||||||
machines = pkgs.lib.concatStrings (map (machine: "
|
machines = pkgs.lib.concatMapStrings (machine: ''
|
||||||
host ${machine.hostName} {
|
host ${machine.hostName} {
|
||||||
hardware ethernet ${machine.ethernetAddress};
|
hardware ethernet ${machine.ethernetAddress};
|
||||||
fixed-address ${machine.ipAddress};
|
fixed-address ${machine.ipAddress};
|
||||||
}
|
}
|
||||||
") cfg.machines);
|
'') cfg.machines;
|
||||||
|
|
||||||
configFile = if cfg.configFile != null then cfg.configFile else pkgs.writeText "dhcpd.conf" "
|
configFile = if cfg.configFile != null then cfg.configFile else pkgs.writeText "dhcpd.conf" ''
|
||||||
default-lease-time 600;
|
default-lease-time 600;
|
||||||
max-lease-time 7200;
|
max-lease-time 7200;
|
||||||
authoritative;
|
authoritative;
|
||||||
ddns-update-style ad-hoc;
|
ddns-update-style ad-hoc;
|
||||||
|
log-facility local1; # see dhcpd.nix
|
||||||
${cfg.extraConfig}
|
${cfg.extraConfig}
|
||||||
${machines}
|
${machines}
|
||||||
";
|
'';
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
name = "dhcpd";
|
name = "dhcpd";
|
||||||
|
|
||||||
job = "
|
job = ''
|
||||||
description \"DHCP server\"
|
description "DHCP server"
|
||||||
|
|
||||||
start on network-interfaces/started
|
start on network-interfaces/started
|
||||||
stop on network-interfaces/stop
|
stop on network-interfaces/stop
|
||||||
|
|
||||||
script
|
script
|
||||||
|
|
||||||
mkdir -m 755 -p ${stateDir}
|
mkdir -m 755 -p ${stateDir}
|
||||||
|
|
||||||
touch ${stateDir}/dhcpd.leases
|
touch ${stateDir}/dhcpd.leases
|
||||||
|
|
||||||
exec ${pkgs.dhcp}/sbin/dhcpd -f -cf ${configFile} \\
|
exec ${pkgs.dhcp}/sbin/dhcpd -f -cf ${configFile} \
|
||||||
-lf ${stateDir}/dhcpd.leases \\
|
-lf ${stateDir}/dhcpd.leases \
|
||||||
${toString cfg.interfaces}
|
${toString cfg.interfaces}
|
||||||
|
|
||||||
end script
|
end script
|
||||||
";
|
'';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,31 @@
|
|||||||
{sysklogd, writeText}:
|
{sysklogd, writeText, config}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
syslogConf = writeText "syslog.conf" ''
|
syslogConf = writeText "syslog.conf" ''
|
||||||
*.* /dev/tty10
|
*.* /dev/tty10
|
||||||
|
|
||||||
*.=warning;*.=err -/var/log/warn
|
# "local1" is used for dhcpd messages.
|
||||||
*.crit /var/log/warn
|
local1.* -/var/log/dhcpd
|
||||||
|
|
||||||
|
mail.* -/var/log/mail
|
||||||
|
|
||||||
*.* -/var/log/messages
|
*.=warning;*.=err -/var/log/warn
|
||||||
|
*.crit /var/log/warn
|
||||||
|
|
||||||
|
*.*;mail.none;local1.none -/var/log/messages
|
||||||
'';
|
'';
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
name = "syslogd";
|
name = "syslogd";
|
||||||
job = "
|
job = ''
|
||||||
start on udev
|
start on udev
|
||||||
stop on shutdown
|
stop on shutdown
|
||||||
|
|
||||||
|
env TZ=${config.time.timeZone}
|
||||||
|
|
||||||
respawn ${sysklogd}/sbin/syslogd -n -f ${syslogConf}
|
respawn ${sysklogd}/sbin/syslogd -n -f ${syslogConf}
|
||||||
";
|
'';
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user