2020-11-30 02:03:58 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
stateDir = "/var/lib/dnsmasq";
|
|
|
|
blocklist = "${stateDir}/dnsmasq.blacklist.txt";
|
|
|
|
|
|
|
|
in {
|
2020-12-31 04:29:38 +01:00
|
|
|
# PostgreSQL daily backups
|
|
|
|
services.postgresqlBackup = {
|
|
|
|
enable = true;
|
|
|
|
backupAll = true;
|
|
|
|
location = "/vault/backups/zion/databases";
|
|
|
|
startAt = "*-*-* 05:15:00";
|
|
|
|
};
|
|
|
|
|
2020-11-30 02:03:58 +01:00
|
|
|
# Fetch hosts-blocklists daily
|
|
|
|
systemd.services.download-dns-blocklist = {
|
|
|
|
description = "Download hosts-blocklists";
|
|
|
|
wantedBy = [ "default.target" ];
|
2022-10-23 10:47:58 +02:00
|
|
|
path = with pkgs; [ curl coreutils ];
|
|
|
|
script = ''
|
|
|
|
curl -L https://github.com/notracking/hosts-blocklists/raw/master/dnsmasq/dnsmasq.blacklist.txt -o ${blocklist}
|
|
|
|
sed "/cainiao/d" -i ${blocklist}
|
|
|
|
'';
|
2021-04-15 12:34:38 +02:00
|
|
|
serviceConfig.Type = "oneshot";
|
2020-11-30 02:03:58 +01:00
|
|
|
postStop = ''
|
|
|
|
chown -R dnsmasq ${stateDir}
|
|
|
|
systemctl restart dnsmasq
|
|
|
|
'';
|
2022-03-21 16:25:41 +01:00
|
|
|
after = [ "wireguard-wg0.service" ];
|
2021-04-29 16:47:47 +02:00
|
|
|
startAt = "02:00:00";
|
2020-11-30 02:03:58 +01:00
|
|
|
};
|
|
|
|
|
2021-05-15 16:51:46 +02:00
|
|
|
# Enable SATA HAT
|
2022-07-12 21:02:11 +02:00
|
|
|
systemd.services.sata-hat = {
|
2021-05-15 16:51:46 +02:00
|
|
|
description = "Enable software support for SATA Hat";
|
|
|
|
wantedBy = [ "zfs-import.target" ];
|
|
|
|
script = ''
|
2022-07-12 21:02:11 +02:00
|
|
|
${pkgs.bash}/bin/bash -c "/home/coolneng/system/scripts/SATA-hat.sh on"
|
2022-05-04 19:28:18 +02:00
|
|
|
'';
|
2021-05-15 16:51:46 +02:00
|
|
|
serviceConfig = {
|
|
|
|
Type = "oneshot";
|
|
|
|
RemainAfterExit = "yes";
|
2022-11-14 11:48:26 +01:00
|
|
|
ExecStop = ''
|
|
|
|
${pkgs.bash}/bin/bash -c "/home/coolneng/system/scripts/SATA-hat.sh off"
|
|
|
|
'';
|
2020-11-30 02:03:58 +01:00
|
|
|
};
|
2021-07-28 12:47:21 +02:00
|
|
|
before = [ "zfs-import.target" "zfs-import-vault.service" "umount.target" ];
|
2021-05-15 16:51:46 +02:00
|
|
|
requires = [ "systemd-udev-settle.service" ];
|
|
|
|
after = [ "systemd-udev-settle.service" ];
|
2021-07-28 12:47:21 +02:00
|
|
|
conflicts = [ "umount.target" ];
|
2022-12-12 00:15:47 +01:00
|
|
|
requiredBy = [ "syncthing.service" "radicale.service" "gitea.service" ];
|
2020-11-30 02:03:58 +01:00
|
|
|
};
|
2021-05-21 01:27:27 +02:00
|
|
|
|
|
|
|
# HACK: restart services dependent on ZFS afer mount
|
|
|
|
systemd.services.restart-services-mount = {
|
|
|
|
description = "Restart services after the ZFS dataset is mounted";
|
|
|
|
wantedBy = [ "default.target" ];
|
|
|
|
script = ''
|
|
|
|
sleep 5
|
|
|
|
systemctl restart syncthing
|
|
|
|
systemctl restart radicale
|
|
|
|
systemctl restart gitea
|
2023-02-14 20:59:08 +01:00
|
|
|
systemctl restart podman-openbooks
|
2023-05-10 16:10:59 +02:00
|
|
|
systemctl restart podman-mqtt2prometheus
|
2023-05-24 14:15:15 +02:00
|
|
|
systemctl restart podman-mongodb
|
|
|
|
systemctl restart podman-nightscout
|
2021-05-21 01:27:27 +02:00
|
|
|
'';
|
|
|
|
serviceConfig.Type = "oneshot";
|
|
|
|
requires = [ "sata-hat.service" ];
|
|
|
|
after = [ "vault.mount" ];
|
|
|
|
};
|
2021-05-24 21:44:00 +02:00
|
|
|
|
|
|
|
# Idle HDDs when not used
|
|
|
|
systemd.services.hd-idle = {
|
|
|
|
description = "Idle HDDs when not in use";
|
|
|
|
wantedBy = [ "default.target" ];
|
|
|
|
path = with pkgs; [ hd-idle ];
|
|
|
|
script = "${pkgs.hd-idle}/bin/hd-idle";
|
|
|
|
serviceConfig.Type = "simple";
|
|
|
|
requires = [ "sata-hat.service" ];
|
|
|
|
after = [ "vault.mount" ];
|
|
|
|
};
|
2022-06-07 00:11:57 +02:00
|
|
|
|
|
|
|
# Push zion changes to git daily
|
2022-06-17 17:15:27 +02:00
|
|
|
systemd.user.services.zion-push = {
|
2022-06-07 00:11:57 +02:00
|
|
|
description = "Push zion changes to git";
|
2022-07-20 10:15:40 +02:00
|
|
|
wantedBy = [ "default.target" ];
|
2022-06-07 00:11:57 +02:00
|
|
|
path = with pkgs; [ git ];
|
2022-06-19 09:29:07 +02:00
|
|
|
script = ''
|
|
|
|
${pkgs.git}/bin/git -C /home/coolneng/system pull
|
|
|
|
${pkgs.git}/bin/git -C /home/coolneng/system push
|
|
|
|
'';
|
2022-06-07 00:11:57 +02:00
|
|
|
serviceConfig.Type = "oneshot";
|
|
|
|
startAt = "07:00:00";
|
|
|
|
after = [ "network-online.target" ];
|
|
|
|
};
|
2020-11-30 02:03:58 +01:00
|
|
|
}
|