Compare commits
1 Commits
fax-machin
...
mob/asteri
Author | SHA1 | Date | |
---|---|---|---|
4704dd43fa |
64
modules/clan/asterisk/default.nix
Normal file
64
modules/clan/asterisk/default.nix
Normal file
@@ -0,0 +1,64 @@
|
||||
{ ... }:
|
||||
{
|
||||
_class = "clan.service";
|
||||
manifest.name = "asterisk";
|
||||
manifest.description = "Asterisk PBX server";
|
||||
manifest.categories = [ "System" ];
|
||||
|
||||
roles.default = {
|
||||
perInstance.nixosModule =
|
||||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
{
|
||||
services.asterisk = {
|
||||
enable = lib.mkDefault true;
|
||||
confFiles = {
|
||||
"extensions.conf" = ''
|
||||
[tests]
|
||||
; Dial 100 for "hello, world"
|
||||
exten => 100,1,Answer()
|
||||
same => n,Wait(1)
|
||||
same => n,Playback(hello-world)
|
||||
same => n,Hangup()
|
||||
|
||||
[softphones]
|
||||
include => tests
|
||||
|
||||
[unauthorized]
|
||||
'';
|
||||
"sip.conf" = ''
|
||||
[general]
|
||||
allowguest=no ; Require authentication
|
||||
context=unauthorized ; Send unauthorized users to /dev/null
|
||||
srvlookup=no ; Don't do DNS lookup
|
||||
udpbindaddr=0.0.0.0 ; Listen on all interfaces
|
||||
nat=force_rport,comedia ; Assume device is behind NAT
|
||||
|
||||
[softphone](!)
|
||||
type=friend ; Match on username first, IP second
|
||||
context=softphones ; Send to softphones context in
|
||||
; extensions.conf file
|
||||
host=dynamic ; Device will register with asterisk
|
||||
disallow=all ; Manually specify codecs to allow
|
||||
allow=g722
|
||||
allow=ulaw
|
||||
allow=alaw
|
||||
|
||||
[myphone](softphone)
|
||||
secret=GhoshevFew ; Change this password!
|
||||
'';
|
||||
"logger.conf" = ''
|
||||
[general]
|
||||
|
||||
[logfiles]
|
||||
; Add debug output to log
|
||||
syslog.local0 => notice,warning,error,debug
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
18
modules/clan/asterisk/flake-module.nix
Normal file
18
modules/clan/asterisk/flake-module.nix
Normal file
@@ -0,0 +1,18 @@
|
||||
{ lib, ... }:
|
||||
let
|
||||
module = lib.modules.importApply ./default.nix { };
|
||||
in
|
||||
{
|
||||
clan.modules = {
|
||||
asterisk = module;
|
||||
};
|
||||
perSystem =
|
||||
{ ... }:
|
||||
{
|
||||
clan.nixosTests.asterisk = {
|
||||
imports = [ ./tests/vm/default.nix ];
|
||||
|
||||
clan.modules."@clan/asterisk" = module;
|
||||
};
|
||||
};
|
||||
}
|
39
modules/clan/asterisk/tests/vm/default.nix
Normal file
39
modules/clan/asterisk/tests/vm/default.nix
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
{
|
||||
name = "service-asterisk";
|
||||
|
||||
clan = {
|
||||
directory = ./.;
|
||||
inventory = {
|
||||
machines.server = { };
|
||||
|
||||
instances = {
|
||||
asterisk-test = {
|
||||
module.name = "@clan/asterisk";
|
||||
module.input = "self";
|
||||
roles.default.machines."server".settings = { };
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
nodes = {
|
||||
server = {
|
||||
services.asterisk = {
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
start_all()
|
||||
|
||||
server.wait_for_unit("asterisk")
|
||||
|
||||
# Check that garage is running
|
||||
server.succeed("systemctl status asterisk")
|
||||
|
||||
'';
|
||||
}
|
Reference in New Issue
Block a user