···
cfg = config.services.smokeping;
smokepingHome = "/var/lib/smokeping";
smokepingPidDir = "/run";
+
contact = ${cfg.ownerEmail}
+
${lib.optionalString (cfg.mailHost != "") "mailhost = ${cfg.mailHost}"}
+
${lib.optionalString (cfg.sendmail != null) "sendmail = ${cfg.sendmail}"}
+
imgcache = ${smokepingHome}/cache
+
imgurl = http://${cfg.hostName}:${builtins.toString cfg.port}/cache
+
datadir = ${smokepingHome}/data
+
pagedir = ${smokepingHome}/cache
+
piddir = ${smokepingPidDir}
+
cgiurl = http://${cfg.hostName}:${builtins.toString cfg.port}/smokeping.cgi
+
linkstyle = ${cfg.linkStyle}
+
smokemail = ${cfg.smokeMailTemplate}
+
template = ${cfg.presentationTemplate}
+
${cfg.presentationConfig}
configPath = pkgs.writeText "smokeping.conf" configFile;
cgiHome = pkgs.writeScript "smokeping.fcgi" ''
···
+
description = "Use this SMTP server to send alerts";
+
type = types.nullOr types.path;
+
example = "/var/setuid-wrappers/sendmail";
+
description = "Use this sendmail compatible script to deliver alerts";
smokeMailTemplate = mkOption {
···
default = pkgs.smokeping;
+
defaultText = "pkgs.smokeping";
description = "Specify a custom smokeping package";
···
default = config.networking.hostName;
example = "somewhere.example.com";
+
description = "DNS name for the urls generated in the cgi.";
+
type = types.enum ["original" "absolute" "relative"];
description = "DNS name for the urls generated in the cgi.";
···
+
from = smokeping@localhost
example = literalExample ''
to = alertee@address.somewhere
from = smokealert@company.xy
···
description = "Any additional customization not already included.";
+
type = types.nullOr types.string;
+
description = "Full smokeping config supplied by the user. Overrides " +
+
"and replaces any other configuration supplied.";
config = mkIf cfg.enable {
+
assertion = !(cfg.sendmail != null && cfg.mailHost != "");
+
message = "services.smokeping: sendmail and Mailhost cannot both be enabled.";
+
security.setuidPrograms = [ "fping" ];
+
environment.systemPackages = [ pkgs.fping ];
users.extraUsers = singleton {
···
serviceConfig.PermissionsStartOnly = true;
mkdir -m 0755 -p ${smokepingHome}/cache ${smokepingHome}/data
+
rm -f ${smokepingHome}/cropper
+
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}
+
${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"];
+
path = with pkgs; [ bash rrdtool smokeping thttpd ];
+
script = ''thttpd -u ${cfg.user} -c "**.fcgi" -d ${smokepingHome} -p ${builtins.toString cfg.port} -D -nos'';
+
serviceConfig.Restart = "always";