nix-infra/config/hosts/yate/service.nix

51 lines
1.7 KiB
Nix
Raw Normal View History

2024-06-08 22:18:23 +02:00
{ config, pkgs, ... }:
{
2024-08-06 22:06:26 +02:00
# systemd.managerEnvironment = {
# SYSTEMD_LOG_LEVEL = "debug";
# };
sops.secrets."git_clone_key" = {
mode = "0600";
owner = "root";
group = "yate-config";
restartUnits = [ "yate.service" ];
};
2024-06-08 22:18:23 +02:00
systemd.services.yate = {
enable = true;
description = "Yate telehony engine";
unitConfig = {
Type = "simple";
2024-08-06 22:06:26 +02:00
After= "network.target";
2024-06-08 22:18:23 +02:00
};
serviceConfig = {
ExecStart = "${pkgs.yate}/bin/yate -c /etc/yate -e /etc/yate/share -Do";
2024-06-08 22:18:23 +02:00
Type="simple";
Restart="always";
2024-08-06 22:06:26 +02:00
User="root";
2024-08-05 20:58:09 +02:00
Group="yate-config";
StateDirectory = "yate";
StateDirectoryMode = "0775";
2024-06-08 22:18:23 +02:00
# ...
};
wantedBy = [ "default.target" ];
requiredBy = [ "network.target" ];
2024-08-06 22:06:26 +02:00
preStart = "echo \"\n\" >> /run/secrets/git_clone_key
if ! [ -d \"/var/lib/yate/.git\" ]
then
2024-08-05 20:58:09 +02:00
${pkgs.git}/bin/git init /var/lib/yate
${pkgs.git}/bin/git -C /var/lib/yate remote add origin forgejo@git.hamburg.ccc.de:echtnurich/yate-config.git
2024-08-06 22:06:26 +02:00
env GIT_SSH_COMMAND=\"${pkgs.openssh}/bin/ssh -i /run/secrets/git_clone_key\" ${pkgs.git}/bin/git -C /var/lib/yate pull -f --set-upstream
2024-08-05 20:58:09 +02:00
echo \"New repo set up.\"
fi
2024-08-06 22:06:26 +02:00
test ${pkgs.openssh}/bin/ssh
${pkgs.git}/bin/git -C /var/lib/yate config --add safe.directory \"/var/lib/yate\"
env GIT_SSH_COMMAND=\"${pkgs.openssh}/bin/ssh -i /run/secrets/git_clone_key\" ${pkgs.git}/bin/git -C /var/lib/yate fetch --all
2024-08-05 20:58:09 +02:00
${pkgs.git}/bin/git -C /var/lib/yate checkout --track -f origin/master";
2024-06-08 22:18:23 +02:00
# ...
};
}