1
0

add fieldpoc dect claim script

This commit is contained in:
Ember 'n0emis' Keske 2022-07-21 00:55:10 +02:00
parent 9795ed55b8
commit 03957afd7e
No known key found for this signature in database
GPG Key ID: 00FAF748B777CF10
7 changed files with 49 additions and 5 deletions

View File

@ -2,7 +2,7 @@ keys:
- &admin_clerie DD2D88B9FCB74C81E6F63AAD5B5D448C88684BC3 - &admin_clerie DD2D88B9FCB74C81E6F63AAD5B5D448C88684BC3
- &admin_n0emis 6E10217E3187069E057DF5ABE0262A773B824745 - &admin_n0emis 6E10217E3187069E057DF5ABE0262A773B824745
- &host_nerd age1x69924s94z4k7s50utyuqrwshpt8p8yzwaxny2gle7yeyg4w3spqml95mu - &host_nerd age1x69924s94z4k7s50utyuqrwshpt8p8yzwaxny2gle7yeyg4w3spqml95mu
- &host_yate age10pxa70g3ekxdrk788l52s93a6ftavdw3r8x6d23gmsluudmwq3asmu6ah9\ - &host_yate age10pxa70g3ekxdrk788l52s93a6ftavdw3r8x6d23gmsluudmwq3asmu6ah9
- &host_yate_dialup age14zsha5c5238v6hzchdfkjgjjwzc2qc79tl0ngmqrdquck5f945zs35vps4 - &host_yate_dialup age14zsha5c5238v6hzchdfkjgjjwzc2qc79tl0ngmqrdquck5f945zs35vps4
- &host_pre_yate_n0emis age1lrujyz4d48yjelmh6eufxjffuvfm9pusen3uxskyhnyf27xyucdqq3jza5 - &host_pre_yate_n0emis age1lrujyz4d48yjelmh6eufxjffuvfm9pusen3uxskyhnyf27xyucdqq3jza5
creation_rules: creation_rules:

30
hosts/yate/dect_claim.py Normal file
View File

@ -0,0 +1,30 @@
import asyncio
import os
import re
import socket
from yate.ivr import YateIVR
SOUNDS_PATH = "/run/current-system/sw/share/sounds/yate"
async def main(ivr: YateIVR):
caller_id = ivr.call_params.get("caller", "")
caller_id = re.sub("[^\\d]", "", caller_id)
called_id = ivr.call_params.get("called", "")
called_id = re.sub("[^\\d]", "", called_id)
await ivr.play_soundfile(
os.path.join(SOUNDS_PATH, "yintro.slin"),
complete=True)
await asyncio.sleep(0.5)
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect(("localhost", 9437))
s.recv(1024)
s.sendall(f"claim {caller_id} {called_id}".encode('utf-8'))
s.recv(1024)
app = YateIVR()
app.run(main)

View File

@ -42,4 +42,12 @@
[dialin] [dialin]
\${sip_x-called}^.*$=lateroute/\\1"; \${sip_x-called}^.*$=lateroute/\\1";
}; };
environment.systemPackages = with pkgs; [
(writers.makePythonWriter python39 python39.pkgs "/bin/dect_claim" { libraries = [ python39.pkgs.python-yate ]; } (builtins.readFile ./dect_claim.py))
(runCommand "yintro.slin" {} ''
mkdir -p $out/share/sounds/yate
ln -s ${./yintro.slin} $out/share/sounds/yate/yintro.slin
'')
];
} }

BIN
hosts/yate/yintro.slin Normal file

Binary file not shown.

View File

@ -20,12 +20,16 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [
python3.pkgs.fieldpoc
];
services.postgresql = { services.postgresql = {
enable = true; enable = true;
initialScript = pkgs.writeText "backend-initScript" '' initialScript = pkgs.writeText "backend-initScript" ''
CREATE ROLE nixcloud WITH LOGIN PASSWORD 'nixcloud' CREATEDB; CREATE ROLE fieldpoc WITH LOGIN PASSWORD 'fieldpoc' CREATEDB;
CREATE DATABASE nixcloud; CREATE DATABASE fieldpoc;
GRANT ALL PRIVILEGES ON DATABASE nixcloud TO nixcloud; GRANT ALL PRIVILEGES ON DATABASE fieldpoc TO fieldpoc;
''; '';
}; };

View File

@ -6,6 +6,8 @@ self: super: {
python3 = let packageOverrides = final: prev: import ./python final prev; python3 = let packageOverrides = final: prev: import ./python final prev;
in super.python3.override { inherit packageOverrides; }; in super.python3.override { inherit packageOverrides; };
python39 = let packageOverrides = final: prev: import ./python final prev;
in super.python39.override { inherit packageOverrides; };
yate = super.yate.overrideAttrs (old: { yate = super.yate.overrideAttrs (old: {
configureFlags = configureFlags =

View File

@ -7,7 +7,7 @@ buildPythonApplication rec {
src = fetchGit { src = fetchGit {
url = "https://git.n0emis.eu/n0emis/fieldpoc.git"; url = "https://git.n0emis.eu/n0emis/fieldpoc.git";
ref = "main"; ref = "main";
rev = "d6d664b4690189a7ed54be65ceef8cb3d79a6bfb"; rev = "2f1347f3415249cb116501af1f5e3282afca24be";
}; };
format = "pyproject"; format = "pyproject";