Merge branch 'spring_back'

This commit is contained in:
MathewFrancis 2025-04-24 14:14:58 +05:30
commit 58ed8555f1
295 changed files with 2431 additions and 1845 deletions

View File

@ -0,0 +1,2 @@
DB_USER=asterisk_user
DB_PASS=12345

View File

@ -1,21 +1,10 @@
FROM andrius/asterisk:edge
FROM mathewfrancisv/odbc_mariadb:v3.0.2
# Add edge/testing repository
# RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories && \
RUN apk update && \
apk upgrade && \
apk add asterisk-odbc && \
apk add unixodbc && \
apk add unixodbc-dev && \
apk add mariadb-connector-odbc && \
mkdir -p /etc/asterisk/moh
# call_transfer
# apk add --no-cache unixodbc unixodbc-dev mariadb-connector-odbc
# Copy custom Asterisk config files
#COPY asterisk_config/ /etc/asterisk/
#RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories && \
RUN cp -r /usr/share/asterisk/sounds/en /var/lib/asterisk/sounds/
# Start Asterisk in verbose mode
CMD ["asterisk", "-fvvvvv"]
CMD ["asterisk", "-fvvvvv"]

View File

@ -0,0 +1,152 @@
{
"info": {
"_postman_id": "721d5504-301f-488d-a25b-5e78769eac5a",
"name": "CezenPBX_API",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "29498098"
},
"item": [
{
"name": "create a new endpoint",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"id\": \"1005\",\n// \"transport\": \"transport-udp\",\n// \"context\": \"default\",\n// \"disallow\": \"all\",\n// \"allow\": \"ulaw,alaw\",\n// \"directMedia\": \"no\",\n \"connectedLineMethod\": null,\n \"callerid\": null,\n \"dtmfMode\": null,\n// \"mohsuggest\": \"default\",\n \"mailboxes\": null\n}\n\n// {\n// \"id\": \"1004\",\n// \"transport\": \"transport-udp\",\n// \"aors\": \"1004\",\n// \"auth\": \"1004\",\n// \"context\": \"default\",\n// \"disallow\": \"all\",\n// \"allow\": \"ulaw,alaw\",\n// \"directMedia\": \"no\",\n// \"connectedLineMethod\": null,\n// \"callerid\": \"User <1004>\",\n// \"dtmfMode\": null,\n// \"mohsuggest\": \"default\",\n// \"mailboxes\": \"1004@default\"\n// }",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://localhost:8081/cezen/add_user",
"protocol": "http",
"host": [
"localhost"
],
"port": "8081",
"path": [
"cezen",
"add_user"
]
}
},
"response": []
},
{
"name": "create a new extension",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"context\": \"default\",\n \"extension\": \"1005\",\n \"priority\": 1,\n \"app\": \"Dial\",\n \"appdata\": \"PJSIP/1005,20,m(default)\"\n}\n",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://localhost:8081/cezen/add_extension",
"protocol": "http",
"host": [
"localhost"
],
"port": "8081",
"path": [
"cezen",
"add_extension"
]
}
},
"response": []
},
{
"name": "set_password",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"id\": \"1005\",\n \"authType\": \"userpass\",\n \"userName\": \"1005\",\n \"password\": \"12345\",\n \"md5Cred\": null,\n \"realm\": null\n}\n",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://localhost:8081/cezen/set_password",
"protocol": "http",
"host": [
"localhost"
],
"port": "8081",
"path": [
"cezen",
"set_password"
]
}
},
"response": []
},
{
"name": "SetAORS",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"id\": \"1005\",\n \"maxContacts\": 1\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://localhost:8081/cezen/set_aors",
"protocol": "http",
"host": [
"localhost"
],
"port": "8081",
"path": [
"cezen",
"set_aors"
]
}
},
"response": []
},
{
"name": "DeleteExtension",
"request": {
"method": "DELETE",
"header": [],
"url": {
"raw": "http://localhost:8081/cezen/delete_extension?sipNumber=testEndPoint",
"protocol": "http",
"host": [
"localhost"
],
"port": "8081",
"path": [
"cezen",
"delete_extension"
],
"query": [
{
"key": "sipNumber",
"value": "testEndPoint"
}
]
}
},
"response": []
}
]
}

View File

@ -25,7 +25,14 @@
; Formats for writing Voicemail. Note that when using IMAP storage for
; voicemail, only the first format specified will be used.
;format=g723sf|wav49|wav
format=wav49|gsm|wav
format=wav
serveremail=asterisk
attach=yes
delete=no
language=en
mailboxdir=/usr/share/asterisk/voicemail
;
; WARNING:
; If you change the list of formats that you record voicemail in

View File

@ -0,0 +1,42 @@
USE asterisk_db;
SHOW DATABASES;
SHOW TABLES;
SELECT * FROM `ps_endpoints`;
DELETE FROM `ps_endpoints` WHERE `id` = '1004';
SELECT * FROM `extensions_table`;
DESCRIBE `extensions_table`;
ALTER TABLE `extensions_table`
ADD CONSTRAINT `extension_table_unique_val_two_check` UNIQUE (`exten`, `appdata`);
ALTER TABLE `extensions_table`
DROP INDEX `extension_table_unique_val`;
ALTER TABLE `extensions_table`
ADD CONSTRAINT `extension_table_unique_val` UNIQUE (`exten`, `appdata`, `priority`);
DELETE FROM `extensions_table` WHERE priority = 4 and exten = "1005" ;
DELETE FROM `extensions_table` WHERE exten = "1005" OR exten = "1004";
DELETE FROM `ps_endpoints` WHERE id = "1004" OR id = "1005";
DELETE FROM `extensions_table` WHERE exten = "1004" OR exten = "1005";
SELECT * FROM `extensions_table` WHERE app = "Dial";
--
SELECT * FROM ps_auths;
SELECT * FROM ps_aors;
DESCRIBE `ps_auths`;
DESCRIBE `ps_aors`;
INSERT INTO `ps_aors`(`id`,`max_contacts`) VALUES ("1004", 1);
INSERT INTO `ps_auths`(`id`, `auth_type`, `username`, `password`, `md5_cred`, `realm`) VALUES("1004", "userpass", "1004", "12345", null, null);

View File

@ -169,3 +169,4 @@ SELECT * FROM extensions_table WHERE context='default';
SHOW TABLES;
#

View File

@ -0,0 +1,285 @@
USE asterisk_db;
show tables;
CREATE TABLE ps_endpoints (
id VARCHAR(40) NOT NULL PRIMARY KEY,
transport VARCHAR(40) NULL,
aors VARCHAR(200) NULL UNIQUE,
auth VARCHAR(40) NULL UNIQUE,
context VARCHAR(40) NULL,
disallow VARCHAR(200) NULL,
allow VARCHAR(200) NULL,
direct_media VARCHAR(40) NULL,
connected_line_method VARCHAR(40) NULL,
callerid VARCHAR(40) NULL,
dtmf_mode VARCHAR(40) NULL
);
CREATE TABLE ps_auths (
id VARCHAR(40) NOT NULL PRIMARY KEY,
auth_type VARCHAR(40) NOT NULL,
username VARCHAR(40) NULL UNIQUE,
password VARCHAR(40) NULL,
md5_cred VARCHAR(40) NULL,
realm VARCHAR(40) NULL
);
CREATE TABLE ps_aors (
id VARCHAR(40) NOT NULL PRIMARY KEY,
max_contacts INTEGER USE asterisk_db;
NULL
);
CREATE TABLE extensions_table (
id INT AUTO_INCREMENT PRIMARY KEY,
context VARCHAR(50) NOT NULL,
exten VARCHAR(50) NOT NULL UNIQUE,
priority INT NOT NULL,
app VARCHAR(50) NOT NULL,
appdata VARCHAR(100)
);
INSERT INTO ps_endpoints (id, transport, aors, auth, context, disallow, allow)
VALUES ('1001', 'transport-udp', '1001', '1001', 'default', 'all', 'ulaw,alaw');
INSERT INTO ps_auths (id, auth_type, username, password)
VALUES ('1001', 'userpass', '1001', '12345');
INSERT INTO ps_aors (id, max_contacts)
VALUES ('1001', 1);
-- Add Endpoint for 1002
INSERT INTO ps_endpoints (id, transport, aors, auth, context, disallow, allow, direct_media)
VALUES ('1002', 'transport-udp', '1002', '1002', 'default', 'all', 'ulaw,alaw', 'no');
-- Add Authentication for 1002
INSERT INTO ps_auths (id, auth_type, username, password)
VALUES ('1002', 'userpass', '1002', '12345');
-- Add AOR (Address of Record) for 1002
INSERT INTO ps_aors (id, max_contacts)
VALUES ('1002', 2);
INSERT INTO ps_endpoints (id, transport, aors, auth, context, disallow, allow, direct_media)
VALUES ('1003', 'transport-udp', '1003', '1003', 'default', 'all', 'ulaw,alaw', 'no');
-- Add Authentication for 1002
INSERT INTO ps_auths (id, auth_type, username, password)
VALUES ('1003', 'userpass', '1003', '12345');
-- Add AOR (Address of Record) for 1002
INSERT INTO ps_aors (id, max_contacts)
VALUES ('1003', 2);
INSERT INTO extensions_table (context, exten, priority, app, appdata)
VALUES
('default', '1001', 1, 'Dial', 'PJSIP/1001,20'),
('default', '1002', 1, 'Dial', 'PJSIP/1002,20'),
('default', '1003', 1, 'Dial', 'PJSIP/1003,20');
SELECT * FROM extensions_table;
-- DROP TABLE `extensions_table`;
SELECT * FROM extensions_table WHERE context='default';
SHOW TABLES;
select * from ps_endpoints;
select * from ps_auths;
select * from ps_aors;
select * from extensions_table;
ALTER TABLE ps_endpoints DROP COLUMN mailboxes;
ALTER TABLE ps_endpoints DROP COLUMN mohsuggest;
ALTER TABLE ps_endpoints ADD mohsuggest VARCHAR(40);
ALTER TABLE ps_endpoints ADD mailboxes VARCHAR(255);
UPDATE ps_endpoints SET mohsuggest = 'default' WHERE id IN ('1001', '1002', '1003');
UPDATE ps_aors SET max_contacts = 1 WHERE id = '1001';
show tables;
-- voice mail usertable ---
CREATE TABLE voicemail_users (
context VARCHAR(20), -- Which group or environment (usually 'default')
mailbox VARCHAR(20), -- The voicemail box number (usually same as extension)
password VARCHAR(20), -- PIN to access the voicemail
fullname VARCHAR(50), -- Users name
email VARCHAR(100) -- Where to send the voicemail recording
);
INSERT INTO voicemail_users (context, mailbox, password, fullname, email)
VALUES
('default', '1001', '1234', 'User One', 'djangod56@gmail.com'),
('default', '1002', '1234', 'User Two', 'djangod56@gmail.com'),
('default', '1003', '1234', 'User Three','djangod56@gmail.com');
select * from voicemail_users;
-- table end --
INSERT INTO extensions_table (context, exten, priority, app, appdata) VALUES
('default', '1001', 30, 'VoiceMail', '1001@default,u'),
('default', '1001', 40, 'Hangup', ''),
('default', '1002', 30, 'VoiceMail', '1002@default,u'),
('default', '1002', 40, 'Hangup', ''),
('default', '1003', 30, 'VoiceMail', '1003@default,u'),
('default', '1003', 40, 'Hangup', '');
select * from extensions_table;
SHOW INDEXES FROM extensions_table;
ALTER TABLE extensions_table DROP INDEX exten;
ALTER TABLE extensions_table DROP PRIMARY KEY;
ALTER TABLE extensions_table ADD PRIMARY KEY (context, exten, priority);
ALTER TABLE extensions_table ADD UNIQUE INDEX unique_exten (context, exten, priority);
SELECT * FROM extensions_table WHERE exten IN ('1001', '1002', '1003') ORDER BY exten, priority;
INSERT INTO extensions_table (context, exten, priority, app, appdata)
VALUES ('default', '555', 2, 'Playback', 'vm-theperson');
delete from extensions_table where appdata = 'vm-theperson';
select * from voicemail_users;
select * from extensions_table;
SHOW TABLES;
SELECT * FROM extensions_table WHERE context = 'default' ORDER BY exten, priority;
DESCRIBE extensions_table;
SELECT * FROM extensions_table WHERE context = 'default' AND exten = '1003';
SHOW INDEXES FROM extensions_table;
UPDATE extensions_table
SET appdata = CONCAT(SUBSTRING_INDEX(appdata, ',', 1), ',su')
WHERE app = 'VoiceMail' AND priority = 2;
select * from extensions_table;
delete from extensions_table where exten ='9999';
UPDATE extensions_table
SET appdata = CONCAT(SUBSTRING_INDEX(appdata, '@', 1), '@default,s')
WHERE app = 'VoiceMail';
SELECT * FROM voicemail_users WHERE mailbox = '1002';
show tables;
select * from voicemail_users;
-- changes in dialplan ---
INSERT INTO extensions_table (context, exten, priority, app, appdata)
VALUES
('default', '1002', 6, 'GotoIf', '${DIALSTATUS}=BUSY?default,1002,30'),
('default', '1002', 7, 'GotoIf', '${DIALSTATUS}=CHANUNAVAIL?default,1002,30'),
('default', '1002', 8, 'GotoIf', '${DIALSTATUS}=NOANSWER?default,1002,30');
INSERT INTO extensions_table (context, exten, priority, app, appdata)
VALUES
('default', '1003', 6, 'GotoIf', '${DIALSTATUS}=BUSY?default,1003,30'),
('default', '1003', 7, 'GotoIf', '${DIALSTATUS}=CHANUNAVAIL?default,1003,30'),
('default', '1003', 8, 'GotoIf', '${DIALSTATUS}=NOANSWER?default,1003,30');
select * from extensions_table;
UPDATE extensions_table
SET appdata = '${DIALSTATUS}=BUSY?default,1002,30'
WHERE exten = '1002' AND priority = 6;
UPDATE extensions_table
SET appdata = '${DIALSTATUS}=CHANUNAVAIL?default,1002,30'
WHERE exten = '1002' AND priority = 7;
UPDATE extensions_table
SET appdata = '${DIALSTATUS}=NOANSWER?default,1002,30'
WHERE exten = '1002' AND priority = 8;
UPDATE extensions_table
SET appdata = '${DIALSTATUS}=BUSY?default,1003,30'
WHERE exten = '1003' AND priority = 6;
UPDATE extensions_table
SET appdata = '${DIALSTATUS}=CHANUNAVAIL?default,1003,30'
WHERE exten = '1003' AND priority = 7;
UPDATE extensions_table
SET appdata = '${DIALSTATUS}=NOANSWER?default,1003,30'
WHERE exten = '1003' AND priority = 8;
INSERT INTO extensions_table (context, exten, priority, app, appdata)
VALUES ('default', '1002', 3, 'Goto', 'default,1002,6');
INSERT INTO extensions_table (context, exten, priority, app, appdata)
VALUES ('default', '1003', 3, 'Goto', 'default,1003,6');
-- change end ---------------
desc extensions_table;
select * from extensions_table;
-- id|context|exten|priority|app |appdata |
-- --+-------+-----+--------+-----------+-----------------------------------------+
-- 1|default|1001 | 2|Dial |PJSIP/1001,20,m(default) |
-- 2|default|1002 | 2|Dial |PJSIP/1002,20,m(default) |
-- 3|default|1003 | 2|Dial |PJSIP/1003,20,m(default) |
-- 4|default|1001 | 1|MixMonitor |1001-${UNIQUEID}.wav,b |
-- 5|default|1002 | 1|MixMonitor |1002-${UNIQUEID}.wav,b |
-- 6|default|1003 | 1|MixMonitor |1003-${UNIQUEID}.wav,b |
-- 8|default|1001 | 3|GotoIf |${DIALSTATUS}=BUSY?default,1002,1 |
-- 9|default|1001 | 4|GotoIf |${DIALSTATUS}=CHANUNAVAIL?default,1002,1 |
-- 10|default|1001 | 5|GotoIf |${DIALSTATUS}=NOANSWER?default,1002,1 |
-- 11|default|1001 | 20|MusicOnHold|default |
-- 12|default|1002 | 20|MusicOnHold|default |
-- 13|default|1003 | 20|MusicOnHold|default |
-- 14|default|1001 | 30|VoiceMail |1001@default,u |
-- 15|default|1001 | 40|Hangup | |
-- 16|default|1002 | 30|VoiceMail |1002@default,u |
-- 17|default|1002 | 40|Hangup | |
-- 18|default|1003 | 30|VoiceMail |1003@default,u |
-- 19|default|1003 | 40|Hangup | |
-- 20|default|1002 | 6|GotoIf |${DIALSTATUS}=BUSY?default,1002,30 |
-- 21|default|1002 | 7|GotoIf |${DIALSTATUS}=CHANUNAVAIL?default,1002,30|
-- 22|default|1002 | 8|GotoIf |${DIALSTATUS}=NOANSWER?default,1002,30 |
-- 23|default|1003 | 6|GotoIf |${DIALSTATUS}=BUSY?default,1003,30 |
-- 24|default|1003 | 7|GotoIf |${DIALSTATUS}=CHANUNAVAIL?default,1003,30|
-- 25|default|1003 | 8|GotoIf |${DIALSTATUS}=NOANSWER?default,1003,30 |
-- 26|default|1002 | 3|Goto |default,1002,6 |
-- 27|default|1003 | 3|Goto |default,1003,6 |

View File

@ -1,7 +1,7 @@
version: "3.8"
services:
asterisk:
image: mathewfrancisv/odbc_mariadb:v2.0.1
image: mathewfrancisv/odbc_mariadb:v4.0.0
container_name: mat_asterisk
restart: always
tty: true
@ -14,10 +14,12 @@ services:
- ./recordings:/var/spool/asterisk/monitor #for call recording
- ./conf/asterisk/queues.conf:/etc/asterisk/queues.conf
- ./conf/asterisk/asterisk_sounds:/var/lib/asterisk/sounds
- ./voicemail_data:/var/spool/asterisk/voicemail
network_mode: "host"
mariadb:
image: mariadb
container_name: mat_mariadb
@ -32,4 +34,27 @@ services:
- ./mariadb_data:/var/lib/mysql # Persistent data
network_mode: "host"
spring_app:
image: mathewfrancisv/spring_alpine:v1.0.0
container_name: springbackalpine
restart: always
tty: true
depends_on:
- mariadb
- asterisk
volumes:
- ./springCezenPBX:/app # Mount your Spring Boot project
- maven_repo:/root/.m2 # Store Maven dependencies
environment:
SPRING_DATASOURCE_URL: jdbc:mariadb://localhost:3308/asterisk_db # Use host.docker.internal
SPRING_DATASOURCE_USERNAME: ${DB_USER}
SPRING_DATASOURCE_PASSWORD: ${DB_PASS}
network_mode: "host" # Run in host mode
volumes:
maven_repo:
#

View File

@ -0,0 +1,21 @@
FROM andrius/asterisk:edge
# Add edge/testing repository
#RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories && \
RUN apk update && \
apk upgrade && \
apk add asterisk-odbc && \
apk add unixodbc && \
apk add unixodbc-dev && \
apk add mariadb-connector-odbc && \
apk add asterisk-sounds-en && \
mkdir -p /etc/asterisk/moh
# apk add --no-cache unixodbc unixodbc-dev mariadb-connector-odbc
# Copy custom Asterisk config files
#COPY asterisk_config/ /etc/asterisk/
# Start Asterisk in verbose mode
CMD ["asterisk", "-fvvvvv"]

View File

@ -1,2 +0,0 @@
default-character-set=utf8mb4
default-collation=utf8mb4_uca1400_ai_ci

View File

@ -1,184 +0,0 @@
24,3
24,2
24,1
24,0
22,4
22,3
22,2
22,1
22,0
21,3
21,2
21,1
21,0
13,3
13,2
13,1
13,0
10,3
10,2
10,1
10,0
9,4
9,3
9,2
9,1
9,0
8,5
8,4
8,3
8,2
8,1
8,0
7,3
5,3
4,3
3,2
2,2
1,2
0,9
1,45
3,44
2,44
1,44
3,43
2,43
1,43
3,42
2,42
1,42
3,41
2,41
1,41
3,40
2,40
1,40
3,39
2,39
1,39
3,38
2,38
1,38
3,37
2,37
1,37
3,36
2,36
1,36
3,35
2,35
1,35
3,34
2,34
1,34
3,33
2,33
1,33
3,32
2,32
1,32
3,31
2,31
1,31
3,30
2,30
1,30
3,29
2,29
1,29
3,28
2,28
1,28
3,27
2,27
1,27
3,26
2,26
1,26
3,25
2,25
1,25
3,24
2,24
1,24
3,23
2,23
1,23
3,22
2,22
1,22
3,21
2,21
1,21
3,20
2,20
1,20
3,19
2,19
1,19
3,18
2,18
1,18
3,17
2,17
1,17
3,16
2,16
1,16
3,15
2,15
1,15
3,14
2,14
1,14
3,13
2,13
1,13
3,12
2,12
1,12
3,11
2,11
1,11
3,10
2,10
1,10
3,9
2,9
1,9
3,8
2,8
1,8
3,7
2,7
1,7
3,6
2,6
1,6
3,5
2,5
1,5
3,4
2,4
1,4
3,3
3,0
2,3
2,0
1,3
1,0
0,6
0,0
0,47
0,46
0,49
0,48
0,45
0,12
0,10
0,8
0,11
0,5
0,7
0,4
0,3

View File

@ -1 +0,0 @@
11.7.2-MariaDB

View File

@ -1,2 +0,0 @@
default-character-set=utf8mb4
default-collation=utf8mb4_uca1400_ai_ci

Some files were not shown because too many files have changed in this diff Show More