Skip to content

Commit

Permalink
Create recallonbusy configuration file if it doesn't exist (#317)
Browse files Browse the repository at this point in the history
* Create recallonbusy configuration file if it doesn't exist

This file exist since https://github.com/nethesis/ns8-nethvoice/releases/tag/0.0.1-rc.2.0.1 if NethVoice was installed before it doesn't exist

* Attempt to reconnect if first connection fails

Co-authored-by: Matteo Valentini <[email protected]>

---------

Co-authored-by: Matteo Valentini <[email protected]>

NethServer/dev#7010
  • Loading branch information
Stell0 authored Oct 9, 2024
1 parent c4598ce commit 3eaea88
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
13 changes: 13 additions & 0 deletions freepbx/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,19 @@ while (\$row = \$sth->fetch(\PDO::FETCH_ASSOC)) {
'${NETHCTI_DB_PASSWORD}');
EOF

# create recallonbusy configuration if it doesn't exist
if [[ ! -f /etc/asterisk/recallonbusy.cfg ]]; then
cat > /etc/asterisk/recallonbusy.cfg <<EOF
[recallonbusy]
Host: 127.0.0.1
Port: 5038
Username: CHANGEME
Secret: CHANGEME
Debug : False
CheckInterval: 20
EOF
fi

# configure recallonbusy
sed -i 's/^Port: .*/Port: '${ASTMANAGERPORT}'/' /etc/asterisk/recallonbusy.cfg
sed -i 's/^Username: .*/Username: proxycti/' /etc/asterisk/recallonbusy.cfg
Expand Down
12 changes: 11 additions & 1 deletion freepbx/usr/sbin/recallonbusy
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,17 @@ if __name__ == '__main__':
client = AMIClient('/etc/asterisk/recallonbusy.cfg')
client.add_event_listener(device_state_change_event_listener)
client.add_event_listener(db_get_response_event_listener)
client.connect()
while True:
try:
client.connect()
break
except ConnectionRefusedError as e:
print(f"[recallonbusy] Connection to AMI refused, retrying in 5 seconds...", file=sys.stdout)
time.sleep(5)
except socket.error as e:
print(f"[recallonbusy] ERROR connecting to AMI: {e}", file=sys.stderr)
time.sleep(30)


while True:
try:
Expand Down

0 comments on commit 3eaea88

Please sign in to comment.