add fieldpoc systemd-service
This commit is contained in:
@@ -11,11 +11,18 @@ in {
|
||||
options = {
|
||||
services.fieldpoc = {
|
||||
enable = mkEnableOption "fieldpoc";
|
||||
# TODO: config
|
||||
#config = mkOption {
|
||||
# type = with types; attrsOf anything;
|
||||
# default = { };
|
||||
#};
|
||||
ommIp = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
ommUser = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
ommPasswordPath = mkOption {
|
||||
type = types.path;
|
||||
};
|
||||
sipsecretPath = mkOption {
|
||||
type = types.path;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -24,6 +31,48 @@ in {
|
||||
python3.pkgs.fieldpoc
|
||||
];
|
||||
|
||||
systemd.services.fieldpoc = {
|
||||
description = "Simple phone system";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network-online.target" "yate.service" ];
|
||||
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
ExecStart = "${pkgs.python3.pkgs.fieldpoc}/bin/fieldpoc -c /etc/fieldpoc/config.json -e /etc/fieldpoc/extensions.json --debug";
|
||||
ConfigurationDirectory = "fieldpoc";
|
||||
};
|
||||
|
||||
preStart = let
|
||||
cfgFile = pkgs.writeText "config.json" (lib.generators.toJSON { } {
|
||||
controller = {
|
||||
host = "127.0.0.1";
|
||||
port = 9437;
|
||||
};
|
||||
dect = {
|
||||
host = cfg.ommIp;
|
||||
username = cfg.ommUser;
|
||||
password = "!!OMMPASSWORD!!";
|
||||
sipsecret = "!!SIPSECRET!!";
|
||||
};
|
||||
yate = {
|
||||
host = "127.0.0.1";
|
||||
port = 5039;
|
||||
};
|
||||
database = {
|
||||
hostname = "127.0.0.1";
|
||||
username = "fieldpoc";
|
||||
password = "fieldpoc";
|
||||
database = "fieldpoc";
|
||||
};
|
||||
});
|
||||
in ''
|
||||
${pkgs.gnused}/bin/sed -e "s/!!OMMPASSWORD!!/$(cat ${cfg.ommPasswordPath})/g" -e "s/!!SIPSECRET!!/$(cat ${cfg.sipsecretPath})/g" ${cfgFile} > /etc/fieldpoc/config.json
|
||||
if [ ! -f "/etc/fieldpoc/extensions.json" ]; then
|
||||
echo '{"extensions": {}}' > /etc/fieldpoc/extensions.json
|
||||
fi
|
||||
'';
|
||||
};
|
||||
|
||||
services.postgresql = {
|
||||
enable = true;
|
||||
initialScript = pkgs.writeText "backend-initScript" ''
|
||||
|
Reference in New Issue
Block a user