···
cfg = config.services.smokeping;
smokepingHome = "/var/lib/smokeping";
smokepingPidDir = "/run";
11
-
owner = ${cfg.owner}
12
-
contact = ${cfg.ownerEmail}
13
-
mailhost = ${cfg.mailHost}
14
-
#sendmail = /var/setuid-wrappers/sendmail
15
-
imgcache = ${smokepingHome}/cache
16
-
imgurl = http://${cfg.hostName}:${builtins.toString cfg.port}/cache
17
-
datadir = ${smokepingHome}/data
18
-
piddir = ${smokepingPidDir}
19
-
cgiurl = http://${cfg.hostName}:${builtins.toString cfg.port}/smokeping.cgi
20
-
smokemail = ${cfg.smokeMailTemplate}
21
-
*** Presentation ***
22
-
template = ${cfg.presentationTemplate}
23
-
${cfg.presentationConfig}
27
-
${cfg.databaseConfig}
10
+
if cfg.config == null
14
+
owner = ${cfg.owner}
15
+
contact = ${cfg.ownerEmail}
16
+
${lib.optionalString (cfg.mailHost != "") "mailhost = ${cfg.mailHost}"}
17
+
${lib.optionalString (cfg.sendmail != null) "sendmail = ${cfg.sendmail}"}
18
+
imgcache = ${smokepingHome}/cache
19
+
imgurl = http://${cfg.hostName}:${builtins.toString cfg.port}/cache
20
+
datadir = ${smokepingHome}/data
21
+
pagedir = ${smokepingHome}/cache
22
+
piddir = ${smokepingPidDir}
23
+
cgiurl = http://${cfg.hostName}:${builtins.toString cfg.port}/smokeping.cgi
24
+
linkstyle = ${cfg.linkStyle}
25
+
smokemail = ${cfg.smokeMailTemplate}
26
+
*** Presentation ***
27
+
template = ${cfg.presentationTemplate}
28
+
${cfg.presentationConfig}
32
+
${cfg.databaseConfig}
configPath = pkgs.writeText "smokeping.conf" configFile;
cgiHome = pkgs.writeScript "smokeping.fcgi" ''
···
62
-
default = "127.0.0.1";
63
-
description = "Use this SMTP server rather than localhost";
71
+
example = "localhost";
72
+
description = "Use this SMTP server to send alerts";
74
+
sendmail = mkOption {
75
+
type = types.nullOr types.path;
77
+
example = "/var/setuid-wrappers/sendmail";
78
+
description = "Use this sendmail compatible script to deliver alerts";
smokeMailTemplate = mkOption {
···
default = pkgs.smokeping;
89
+
defaultText = "pkgs.smokeping";
description = "Specify a custom smokeping package";
···
default = config.networking.hostName;
example = "somewhere.example.com";
102
+
description = "DNS name for the urls generated in the cgi.";
104
+
linkStyle = mkOption {
105
+
type = types.enum ["original" "absolute" "relative"];
106
+
default = "relative";
107
+
example = "absolute";
description = "DNS name for the urls generated in the cgi.";
···
158
+
to = root@localhost
159
+
from = smokeping@localhost
example = literalExample ''
to = alertee@address.somewhere
from = smokealert@company.xy
···
description = "Any additional customization not already included.";
251
+
config = mkOption {
252
+
type = types.nullOr types.string;
254
+
description = "Full smokeping config supplied by the user. Overrides " +
255
+
"and replaces any other configuration supplied.";
config = mkIf cfg.enable {
265
+
assertion = !(cfg.sendmail != null && cfg.mailHost != "");
266
+
message = "services.smokeping: sendmail and Mailhost cannot both be enabled.";
269
+
security.setuidPrograms = [ "fping" ];
270
+
environment.systemPackages = [ pkgs.fping ];
users.extraUsers = singleton {
···
serviceConfig.PermissionsStartOnly = true;
mkdir -m 0755 -p ${smokepingHome}/cache ${smokepingHome}/data
285
+
rm -f ${smokepingHome}/cropper
286
+
ln -s ${cfg.package}/htdocs/cropper ${smokepingHome}/cropper
chown -R ${cfg.user} ${smokepingHome}
cp ${cgiHome} ${smokepingHome}/smokeping.fcgi
${cfg.package}/bin/smokeping --check --config=${configPath}
290
+
${cfg.package}/bin/smokeping --static --config=${configPath}
script = ''${cfg.package}/bin/smokeping --config=${configPath} --nodaemon'';
···
wantedBy = [ "multi-user.target"];
requires = [ "smokeping.service"];
partOf = [ "smokeping.service"];
256
-
path = with pkgs; [ bash rrdtool smokeping ];
257
-
script = ''${pkgs.thttpd}/bin/thttpd -u ${cfg.user} -c "**.fcgi" -d ${smokepingHome} -p ${builtins.toString cfg.port} -D'';
298
+
path = with pkgs; [ bash rrdtool smokeping thttpd ];
299
+
script = ''thttpd -u ${cfg.user} -c "**.fcgi" -d ${smokepingHome} -p ${builtins.toString cfg.port} -D -nos'';
300
+
serviceConfig.Restart = "always";