Merge pull request #227203 from badele/fix-smokeping-symbolic-links

nixos/smokeping: fix smokeping symbolic links
This commit is contained in:
Ryan Lahfa 2023-06-06 16:02:58 +02:00 committed by GitHub
commit a06d736f1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,36 +8,36 @@ let
smokepingPidDir = "/run";
configFile =
if cfg.config == null
then
''
*** General ***
cgiurl = ${cfg.cgiUrl}
contact = ${cfg.ownerEmail}
datadir = ${smokepingHome}/data
imgcache = ${smokepingHome}/cache
imgurl = ${cfg.imgUrl}
linkstyle = ${cfg.linkStyle}
${lib.optionalString (cfg.mailHost != "") "mailhost = ${cfg.mailHost}"}
owner = ${cfg.owner}
pagedir = ${smokepingHome}/cache
piddir = ${smokepingPidDir}
${lib.optionalString (cfg.sendmail != null) "sendmail = ${cfg.sendmail}"}
smokemail = ${cfg.smokeMailTemplate}
*** Presentation ***
template = ${cfg.presentationTemplate}
${cfg.presentationConfig}
*** Alerts ***
${cfg.alertConfig}
*** Database ***
${cfg.databaseConfig}
*** Probes ***
${cfg.probeConfig}
*** Targets ***
${cfg.targetConfig}
${cfg.extraConfig}
''
else
cfg.config;
then
''
*** General ***
cgiurl = ${cfg.cgiUrl}
contact = ${cfg.ownerEmail}
datadir = ${smokepingHome}/data
imgcache = ${smokepingHome}/cache
imgurl = ${cfg.imgUrl}
linkstyle = ${cfg.linkStyle}
${lib.optionalString (cfg.mailHost != "") "mailhost = ${cfg.mailHost}"}
owner = ${cfg.owner}
pagedir = ${smokepingHome}/cache
piddir = ${smokepingPidDir}
${lib.optionalString (cfg.sendmail != null) "sendmail = ${cfg.sendmail}"}
smokemail = ${cfg.smokeMailTemplate}
*** Presentation ***
template = ${cfg.presentationTemplate}
${cfg.presentationConfig}
*** Alerts ***
${cfg.alertConfig}
*** Database ***
${cfg.databaseConfig}
*** Probes ***
${cfg.probeConfig}
*** Targets ***
${cfg.targetConfig}
${cfg.extraConfig}
''
else
cfg.config;
configPath = pkgs.writeText "smokeping.conf" configFile;
cgiHome = pkgs.writeScript "smokeping.fcgi" ''
@ -141,7 +141,7 @@ in
'';
};
linkStyle = mkOption {
type = types.enum ["original" "absolute" "relative"];
type = types.enum [ "original" "absolute" "relative" ];
default = "relative";
example = "absolute";
description = lib.mdDoc "DNS name for the urls generated in the cgi.";
@ -301,7 +301,8 @@ in
];
security.wrappers = {
fping =
{ setuid = true;
{
setuid = true;
owner = "root";
group = "root";
source = "${pkgs.fping}/bin/fping";
@ -339,16 +340,16 @@ in
};
preStart = ''
mkdir -m 0755 -p ${smokepingHome}/cache ${smokepingHome}/data
ln -sf ${cfg.package}/htdocs/css ${smokepingHome}/css
ln -sf ${cfg.package}/htdocs/js ${smokepingHome}/js
ln -sf ${cgiHome} ${smokepingHome}/smokeping.fcgi
ln -snf ${cfg.package}/htdocs/css ${smokepingHome}/css
ln -snf ${cfg.package}/htdocs/js ${smokepingHome}/js
ln -snf ${cgiHome} ${smokepingHome}/smokeping.fcgi
${cfg.package}/bin/smokeping --check --config=${configPath}
${cfg.package}/bin/smokeping --static --config=${configPath}
'';
};
systemd.services.thttpd = mkIf cfg.webService {
requiredBy = [ "multi-user.target"];
requires = [ "smokeping.service"];
requiredBy = [ "multi-user.target" ];
requires = [ "smokeping.service" ];
path = with pkgs; [ bash rrdtool smokeping thttpd ];
serviceConfig = {
Restart = "always";