aboutsummaryrefslogtreecommitdiffstats
path: root/hosts/common/optional/services/asterisk.nix
blob: 7bbd0963839c4aa151fef303a82db637e07d917e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
{ config, lib, pkgs, ... }:
{
  services.asterisk = {
    enable = true;
  };

  sops = {
    secrets = {
      "asterisk/asterisk.conf" = {
        owner = config.users.users.asterisk.name;
        group = config.users.users.asterisk.group;
        mode = "00400";
      };
      "asterisk/cdr.conf" = {
        owner = config.users.users.asterisk.name;
        group = config.users.users.asterisk.group;
        mode = "00400";
      };
      "asterisk/console.conf" = {
        owner = config.users.users.asterisk.name;
        group = config.users.users.asterisk.group;
        mode = "00400";
      };
      "asterisk/extensions.ael" = {
        owner = config.users.users.asterisk.name;
        group = config.users.users.asterisk.group;
        mode = "00400";
      };
      "asterisk/indications.conf" = {
        owner = config.users.users.asterisk.name;
        group = config.users.users.asterisk.group;
        mode = "00400";
      };
      "asterisk/logger.conf" = {
        owner = config.users.users.asterisk.name;
        group = config.users.users.asterisk.group;
        mode = "00400";
      };
      "asterisk/modules.conf" = {
        owner = config.users.users.asterisk.name;
        group = config.users.users.asterisk.group;
        mode = "00400";
      };
      "asterisk/musiconhold.conf" = {
        owner = config.users.users.asterisk.name;
        group = config.users.users.asterisk.group;
        mode = "00400";
      };
      "asterisk/pjsip.conf" = {
        owner = config.users.users.asterisk.name;
        group = config.users.users.asterisk.group;
        mode = "00400";
      };
      "asterisk/pjsip_notify.conf" = {
        owner = config.users.users.asterisk.name;
        group = config.users.users.asterisk.group;
        mode = "00400";
      };
      "asterisk/rtp.conf" = {
        owner = config.users.users.asterisk.name;
        group = config.users.users.asterisk.group;
        mode = "00400";
      };
      "asterisk/voicemail.conf" = {
        owner = config.users.users.asterisk.name;
        group = config.users.users.asterisk.group;
        mode = "00400";
      };
    };
  };

  systemd.services.asterisk = {
    serviceConfig.ExecStart = lib.mkForce "${pkgs.asterisk}/bin/asterisk -U asterisk -C ${config.sops.secrets."asterisk/asterisk.conf".path} -F";
    unitConfig = {
      ConditionPathExists = [
        config.sops.secrets."asterisk/asterisk.conf".path
        config.sops.secrets."asterisk/cdr.conf".path
        config.sops.secrets."asterisk/console.conf".path
        config.sops.secrets."asterisk/extensions.ael".path
        config.sops.secrets."asterisk/indications.conf".path
        config.sops.secrets."asterisk/logger.conf".path
        config.sops.secrets."asterisk/modules.conf".path
        config.sops.secrets."asterisk/musiconhold.conf".path
        config.sops.secrets."asterisk/pjsip.conf".path
        config.sops.secrets."asterisk/pjsip_notify.conf".path
        config.sops.secrets."asterisk/rtp.conf".path
        config.sops.secrets."asterisk/voicemail.conf".path
      ];
    };
    #wantedBy = lib.mkForce [];
  };
}