Added First Wip Config of Asterisk
All checks were successful
/ Check Nix Flake (push) Successful in 1m45s
All checks were successful
/ Check Nix Flake (push) Successful in 1m45s
This commit is contained in:
parent
e66bfcab2f
commit
de10828177
4 changed files with 100 additions and 0 deletions
31
modules/nixos/services/asterisk-phony/default.nix
Normal file
31
modules/nixos/services/asterisk-phony/default.nix
Normal file
|
@ -0,0 +1,31 @@
|
|||
{ inputs, config, lib, pkgs, ... }:
|
||||
let
|
||||
cfg = config.services.asterisk-phony;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
];
|
||||
|
||||
options.services.asterisk-phony = {
|
||||
enable = lib.mkOption {
|
||||
type = with lib.types; uniq bool;
|
||||
default = false;
|
||||
description = "Enable Asterisk Communication";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
services.asterisk = {
|
||||
# See Configuration Options: https://search.nixos.org/options?channel=unstable&type=options&query=asterisk
|
||||
enable = true;
|
||||
confFiles = {
|
||||
"pjsip.conf" = builtins.readFile ./pjsip.conf;
|
||||
"extensions.conf" = builtins.readFile ./extensions.conf;
|
||||
};
|
||||
};
|
||||
|
||||
# Firewall
|
||||
networking.firewall.allowedTCPPorts = [ 8088 8089 ];
|
||||
# networking.firewall.allowedUDPPorts = [ ... ];
|
||||
};
|
||||
}
|
17
modules/nixos/services/asterisk-phony/extensions.conf
Normal file
17
modules/nixos/services/asterisk-phony/extensions.conf
Normal file
|
@ -0,0 +1,17 @@
|
|||
[from-internal]
|
||||
; dial the lecture rooms & backoffice
|
||||
; the syntax is NUMBER,SEQUENCE,FUNCTION
|
||||
; to call someone do Dial(MODULE/account, timeout)
|
||||
exten => 1001,1,Dial(PJSIP/saal1,20)
|
||||
exten => 1002,1,Dial(PJSIP/saal2,20)
|
||||
exten => 1600,1,Dial(PJSIP/backoffice,20)
|
||||
|
||||
; Dial 100 for "hello, world"
|
||||
; this is useful when configuring/debugging clients (snoms)
|
||||
exten => 100,1,Answer()
|
||||
same => n,Wait(1)
|
||||
same => n,Playback(hello-world)
|
||||
same => n,Hangup()
|
||||
; note: "n" is a keyword meaning "the last line's value, plus 1"
|
||||
; "same" is a keyword referring to the last-defined extension
|
||||
|
51
modules/nixos/services/asterisk-phony/pjsip.conf
Normal file
51
modules/nixos/services/asterisk-phony/pjsip.conf
Normal file
|
@ -0,0 +1,51 @@
|
|||
; we use UDP for transport
|
||||
[transport-udp]
|
||||
type=transport
|
||||
protocol=udp
|
||||
bind=0.0.0.0
|
||||
|
||||
; Note: this defines a macro, to shorten the config further down
|
||||
[endpoint_internal](!)
|
||||
type=endpoint
|
||||
context=from-internal
|
||||
disallow=all
|
||||
allow=ulaw
|
||||
|
||||
[auth_userpass](!)
|
||||
type=auth
|
||||
auth_type=userpass
|
||||
|
||||
[aor_dynamic](!)
|
||||
type=aor
|
||||
max_contacts=1
|
||||
|
||||
|
||||
; here come the definitions for our phones, using the macros from above
|
||||
|
||||
; lecture hall 1
|
||||
[saal1](endpoint_internal)
|
||||
auth=saal1
|
||||
aors=saal1
|
||||
[saal1](auth_userpass)
|
||||
; well, maybe set a better password than this
|
||||
password=saal1
|
||||
username=saal1
|
||||
[saal1](aor_dynamic)
|
||||
|
||||
; lecture hall 2
|
||||
[saal2](endpoint_internal)
|
||||
auth=saal2
|
||||
aors=saal2
|
||||
[saal2](auth_userpass)
|
||||
password=saal2
|
||||
username=saal2
|
||||
[saal2](aor_dynamic)
|
||||
|
||||
[backoffice](endpoint_internal)
|
||||
auth=backoffice
|
||||
aors=backoffice
|
||||
[backoffice](auth_userpass)
|
||||
password=backoffice
|
||||
username=backoffice
|
||||
[backoffice](aor_dynamic)
|
||||
|
|
@ -56,6 +56,7 @@
|
|||
};
|
||||
programs.mosh.enable = true;
|
||||
|
||||
services.asterisk-phony.enable = true;
|
||||
|
||||
# Firewall
|
||||
# networking.firewall.allowedTCPPorts = [ ... ];
|
||||
|
|
Loading…
Add table
Reference in a new issue