Skip to content

Commit e42d5da

Browse files
committed
Upload / download file fixes
1 parent 79ec5e8 commit e42d5da

18 files changed

+96
-271
lines changed

asterisk/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ RUN pip install -r /services/requirements.txt
2121

2222
COPY ./docker-entrypoint.sh /
2323

24-
EXPOSE 5060/udp 8088 5038
24+
EXPOSE 5060/udp 5038 8088 8010
2525

2626
ENTRYPOINT ["/docker-entrypoint.sh"]

asterisk/docker-entrypoint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# dockerize templates
44
for i in `find /etc -name '*.tmpl'`; do
5-
dockerize -template "$i":"${i%%.tmpl}"
5+
dockerize -template "$i":"${i%%.tmpl}" && rm "$i"
66
done
77

88
if [ "$1" = "" ]; then

asterisk/etc/asterisk/http.conf.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
servername=Asteriska
44
enabled={{ default .Env.HTTP_ENABLED "no" }}
5-
bindaddr={{ default .Env.BRIDGE_IP "127.0.0.1" }}
5+
bindaddr={{ default .Env.HTTP_LISTEN_ADDRESS "127.0.0.1" }}
66
bindport={{ default .Env.HTTP_PORT "8088" }}
77
enablestatic=yes
88

asterisk/etc/asterisk/manager.conf.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
enabled = {{ default .Env.MANAGER_ENABLED "no" }}
33
webenabled = {{ default .Env.MANAGER_WEB_ENABLED "no" }}
44
port = 5038
5-
bindaddr = {{ default .Env.BRIDGE_IP "127.0.0.1" }}
5+
bindaddr = {{ default .Env.MANAGER_LISTEN_ADDRESS "127.0.0.1" }}
66

77
[{{ default .Env.MANAGER_LOGIN "manager" }}]
88
secret={{ default .Env.MANAGER_PASSWORD "secret" }}
+5-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
[ENV]
2-
31
[odoo]
4-
connection=odoo
5-
loguniqueid=yes
6-
table=asterisk_cdr
7-
alias start => started
8-
alias answer => answered
9-
alias end => ended
10-
usegmtime=yes
2+
enabled => yes
3+
dsn => PostgreSQL-odoo
4+
username => {{ default .Env.DB_USER "odoo" }}
5+
password => {{ default .Env.DB_PASSWORD "odoo" }}
6+
pre-connect => yes

asterisk/etc/supervisord.conf

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ directory=/services
3434
command=python ami_broker.py
3535
redirect_stderr=true
3636

37-
#[program:stasis_apps]
38-
#directory=/services
39-
#command=python stasis_apps.py
40-
#redirect_stderr=true
37+
[program:stasis_apps]
38+
directory=/services
39+
command=python stasis_apps.py
40+
redirect_stderr=true

asterisk/services/ami_broker.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def __init__(self):
3232
setproctitle.setproctitle('ami_broker')
3333
self.ami_disconnected.set()
3434
self.settings['AsteriskHost'] = os.environ.get(
35-
'MANAGER_IP', '127.0.0.1')
35+
'MANAGER_LISTEN_ADDRESS', '127.0.0.1')
3636
self.settings['AmiPort'] = os.environ.get(
3737
'MANAGER_PORT', '5038')
3838
self.settings['AsteriskLogin'] = os.environ.get(
@@ -41,6 +41,8 @@ def __init__(self):
4141
'MANAGER_PASSWORD', 'odoo')
4242
self.settings['AmiHeartbeatInterval'] = os.environ.get(
4343
'MANAGER_HEARTBEAT_INTERVAL', '10')
44+
self.settings['AmiReconnectTimeout'] = int(os.environ.get(
45+
'MANAGER_RECONNECT_TIMEOUT', '5'))
4446
self.spawn(self.ami_connection_loop)
4547
self.spawn(self.ami_heartbeat)
4648

asterisk/services/asterisk_helper.py

+6-20
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,23 @@
99
logging.basicConfig(level=logging.DEBUG)
1010
_logger = logging.getLogger(__name__)
1111

12-
ASTERISK = '/usr/bin/asterisk'
12+
ASTERISK = os.environ.get('ASTERISK_BINARY', '/usr/sbin/asterisk')
13+
ASTERISK_ARGS = '-cr'
14+
SSL_ENABLED = False
15+
LISTEN_ADDRESS = os.environ.get('CONSOLE_LISTEN_ADDRESS', '0.0.0.0')
16+
LISTEN_PORT = int(os.environ.get('CONSOLE_LISTEN_PORT', '8010'))
1317

14-
from conf import *
1518

1619
class MyTermSocket(TermSocket):
1720

1821
def check_origin(self, origin):
1922
return True
2023

2124

22-
class RecordingDeleteHandler(tornado.web.RequestHandler):
23-
def get(self):
24-
# Take only the right part of the path to get rid if ../../etc/password
25-
base_name = os.path.basename(self.get_argument('filename'))
26-
# Now format a clean path
27-
file_path = os.path.join(ASTERISK_RECORDING_FOLDER,
28-
base_name)
29-
if os.path.exists(file_path):
30-
_logger.info('Deleteing {}.'.format(file_path))
31-
os.unlink(file_path)
32-
self.write('DELETED')
33-
else:
34-
_logger.warning('File {} does not exist.'.format(file_path))
35-
self.write('NOT_FOUND')
36-
37-
3825
if __name__ == '__main__':
3926
term_manager = SingleTermManager(shell_command=[ASTERISK, ASTERISK_ARGS])
4027
handlers = [
4128
(r'/websocket', MyTermSocket, {'term_manager': term_manager}),
42-
(r'/delete_recording', RecordingDeleteHandler)
4329
]
4430

4531
# Create SSL context
@@ -52,5 +38,5 @@ def get(self):
5238
# Start server
5339
app = tornado.web.Application(handlers)
5440
server = HTTPServer(app, ssl_options=ssl_ctx)
55-
server.listen(PORT)
41+
server.listen(LISTEN_PORT, address=LISTEN_ADDRESS)
5642
IOLoop.current().start()

asterisk/services/conf.py

-99
This file was deleted.

asterisk/services/mqtt_client.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
# Define Variables
1818
AST_ETC_DIR= "/etc/asterisk"
19-
AST_BINARY = "/usr/sbin/asterisk"
19+
ASTERISK_BINARY = os.environ.get('ASTERISK_BINARY', '/usr/sbin/asterisk')
2020
MQTT_HOST = "broker"
2121
MQTT_PORT = 1883
2222
MQTT_KEEPALIVE_INTERVAL = 45
@@ -123,13 +123,13 @@ def asterisk_commands_worker(self):
123123
# Empty the queue
124124
self.asterisk_commands_queue = []
125125
logging.debug('Calling asterisk reload.')
126-
subprocess.check_call([AST_BINARY, '-rx', 'reload'])
126+
subprocess.check_call([ASTERISK_BINARY, '-rx', 'reload'])
127127
else:
128128
while len(self.asterisk_commands_queue):
129129
# Pop commands and apply one by one
130130
cmd = self.asterisk_commands_queue.pop()
131131
logging.debug('Calling asterisk {}.'.format(cmd))
132-
subprocess.check_call([AST_BINARY, '-rx', cmd])
132+
subprocess.check_call([ASTERISK_BINARY, '-rx', cmd])
133133
# CLear the flag
134134
self.asterisk_commands_flag.clear()
135135

0 commit comments

Comments
 (0)