conditional motd in the motd config
This commit is contained in:
@@ -10,7 +10,24 @@
|
||||
# collect services to display
|
||||
motd_list =
|
||||
mapAttrsToList (_: v: v.motd)
|
||||
(filterAttrs (_: v: v ? motd && v.motd != null) config.homelab);
|
||||
(filterAttrs (
|
||||
_: v:
|
||||
(v.enable or false)
|
||||
&& v ? motd
|
||||
&& v.motd != null
|
||||
)
|
||||
config.homelab);
|
||||
|
||||
motd_gs_list = lib.concatLists (
|
||||
mapAttrsToList (_: v: v.motd_gs)
|
||||
(filterAttrs (
|
||||
_: v:
|
||||
(v.enable or false)
|
||||
&& v ? motd_gs
|
||||
&& v.motd_gs != null
|
||||
)
|
||||
config.gameservers)
|
||||
);
|
||||
in {
|
||||
options.homelab.motd = {
|
||||
enable = mkOption {
|
||||
@@ -78,15 +95,16 @@ in {
|
||||
|
||||
# --- gameservers ---
|
||||
echo -e "''${headings}gameservers:''${reset}"
|
||||
for service in velocity smp superflat bento; do
|
||||
status=$(systemctl is-active $service 2>/dev/null)
|
||||
${lib.concatStringsSep "\n" (map (service: ''
|
||||
status=$(systemctl is-active ${service} 2>/dev/null)
|
||||
|
||||
if [ "$status" = "active" ]; then
|
||||
printf "%-32s%s\n" " ''${active}[$service]''${reset}" "running"
|
||||
printf "%-32s%s\n" " ''${active}[${service}]''${reset}" "running"
|
||||
else
|
||||
printf "%-32s%s\n" " ''${active}[$service]''${reset}" "not running"
|
||||
printf "%-32s%s\n" " ''${active}[${service}]''${reset}" "not running"
|
||||
fi
|
||||
done
|
||||
echo
|
||||
'')
|
||||
motd_gs_list)}
|
||||
'';
|
||||
|
||||
environment.etc."motd".mode = "0755";
|
||||
|
||||
Reference in New Issue
Block a user