pkgs/device-templates: make executable and wrap scripts
parent
02de036ba7
commit
ce49c22d2e
|
@ -16,22 +16,37 @@ let
|
|||
);
|
||||
expandTemplate = name: template: data:
|
||||
self.lib.expandSaltTemplate name (replaceNetmasks template) data;
|
||||
wrapNixShell = script:
|
||||
pkgs.runCommand (builtins.baseNameOf script) {
|
||||
src = script;
|
||||
} ''
|
||||
(
|
||||
echo '#! /usr/bin/env nix-shell'
|
||||
echo '#! nix-shell -i "expect -f" -p expect telnet'
|
||||
cat $src
|
||||
) > $out
|
||||
chmod a+x $out
|
||||
'';
|
||||
|
||||
device-scripts =
|
||||
builtins.mapAttrs (hostname: { role, model, ... }:
|
||||
expandTemplate "${hostname}.sh" (templates role model) ({
|
||||
inherit hostname;
|
||||
pillar = config.salt-pillar;
|
||||
netmasks = self.lib.netmasks;
|
||||
logging = config.salt-pillar.hosts-inet.mgmt.logging;
|
||||
} // optionalAttrs (config.salt-pillar.switches ? ${hostname}) {
|
||||
switch = config.salt-pillar.switches.${hostname};
|
||||
} // optionalAttrs (config.salt-pillar.cpe ? ${hostname}) {
|
||||
conf = config.salt-pillar.cpe.${hostname};
|
||||
})
|
||||
) (filterAttrs (_: { role, ... }:
|
||||
role == "ap" || role == "switch"
|
||||
) config.site.hosts);
|
||||
wrapNixShell (
|
||||
expandTemplate "${hostname}.sh" (templates role model) ({
|
||||
inherit hostname;
|
||||
pillar = config.salt-pillar;
|
||||
netmasks = self.lib.netmasks;
|
||||
logging = config.salt-pillar.hosts-inet.mgmt.logging;
|
||||
} // optionalAttrs (config.salt-pillar.switches ? ${hostname}) {
|
||||
switch = config.salt-pillar.switches.${hostname};
|
||||
} // optionalAttrs (config.salt-pillar.cpe ? ${hostname}) {
|
||||
conf = config.salt-pillar.cpe.${hostname};
|
||||
})
|
||||
)
|
||||
) (
|
||||
filterAttrs (_: { role, ... }:
|
||||
role == "ap" || role == "switch"
|
||||
) config.site.hosts
|
||||
);
|
||||
|
||||
all-device-scripts =
|
||||
pkgs.runCommandLocal "all-device-scripts" {} (
|
||||
|
@ -40,6 +55,7 @@ let
|
|||
|
||||
substitute ${./ap_install_collectd.sh} $out/bin/ap_install_collectd.sh \
|
||||
--replace "{{STATS}}" "${config.site.net.serv.hosts6.dn42.stats}"
|
||||
chmod a+x $out/bin/ap_install_collectd.sh
|
||||
'' +
|
||||
builtins.concatStringsSep "\n" (
|
||||
map (hostname:
|
||||
|
|
Loading…
Reference in New Issue