bbb config stuff

main
yova 2 years ago
parent ee85c6bae6
commit 9bbcd4a97d

@ -2,11 +2,13 @@
## imports
import json
import ovh
import requests
import os, sys
import logging
import logging.handlers
import os, sys
import ovh
import requests
import subprocess
import yaml
from dotenv import load_dotenv
my_logger = logging.getLogger('MyLogger')
@ -32,6 +34,9 @@ client = ovh.Client(
TMPFILE = '/tmp/lastIP'
WEBRTCCONFIGFILE = `/etc/bigbluebutton/bbb-webrtc-sfu/production.yml`
# WEBRTCCONFIGFILE = 'test.yml'
def get_ip():
r = requests.get('http://ipinfo.io')
return (r.json()['ip'])
@ -52,18 +57,26 @@ def set_record(zone, subdomain, ip):
exit()
result = client.post('/domain/zone/' + zone + '/refresh')
return result
return result
def read_config_file():
with open(WEBRTCCONFIGFILE,'r') as file:
webrtc_config = yaml.safe_load(file)
return webrtc_config
def write_config_file(ip):
webrtc_config['mediasoup']['webrtc']['listenIps'][0]['announcedIp']=ip
webrtc_config['mediasoup']['plainRtp']['listenIp']['announcedIp']=ip
webrtc_config['freeswitch']['ip']=ip
with open(WEBRTCCONFIGFILE, 'w') as file:
yaml.dump(webrtc_config, file)
if len(sys.argv) > 2:
if os.path.exists(TMPFILE):
with open(TMPFILE) as file:
try:
lastIP=file.read()
except:
my_logger.critical('error reading ' + TMPFILE)
else:
lastIP = ''
webrtc_config = read_config_file()
lastIP = webrtc_config['freeswitch']['ip']
currentIP = get_ip()
@ -71,8 +84,12 @@ if len(sys.argv) > 2:
my_logger.debug ('IP has not changed since last call')
exit()
if (set_record (sys.argv[1], sys.argv[2], currentIP) == None ):
write_config_file(currentIP)
subprocess.run(["ip","a","del",lastIP + '/32',"dev","lo"])
subprocess.run(["ip","a","add",currentIP,"dev","lo"])
my_logger.debug('IP of ' + sys.argv[2] + '.' + sys.argv[1] + ' successfully changed to ' + currentIP)
else:
my_logger.critical('Couldn\'t change IP')

@ -1,8 +1,10 @@
# Update DNS to current IP
# Configures BBB for DYNDNS
Simple dyndns for OVH API.
Changes domain name with OVH API. Updates an A record to the current IP.
Updates an A record to the current IP.
Updates `/etc/bigbluebutton/bbb-webrtc-sfu/production.yml` to current IP.
Updates loopback device with current IP.
## requirements ubuntu
@ -18,18 +20,22 @@ $ pip install -r requirements.txt
and edit `.env` with credentials from https://www.ovh.com/auth/api/createToken
## run
## run
`dyndns-update ZONE SUBDOMAIN`
## install
Install as user cronjob like
For changing the loopback device IP, this needs root rights.
`*/5 * * * * cd /home/user/ovh-dyndns ; ./dyndns-update.py ZONE SUBDOMAIN`
```
cd /root
git clone git@git.gugelfrei.de:bbb/dyndns-update.git
```
with
Install as user cronjob like
`$ crontab -e`
`*/5 * * * * cd /root/dyndns-update ; ./dyndns-update.py ZONE SUBDOMAIN`
to `/etc/cron.d/bbb`

@ -0,0 +1,17 @@
freeswitch:
ip: 87.142.106.77
sip_ip: 127.0.0.1
kurento:
- ip: 192.168.2.47
url: ws://127.0.0.1:8888/kurento
mediasoup:
plainRtp:
listenIp:
announcedIp: 87.142.106.77
ip: 0.0.0.0
webrtc:
listenIps:
- announcedIp: 87.142.106.77
ip: 0.0.0.0
- announcedIp: 192.168.2.47
ip: 0.0.0.0
Loading…
Cancel
Save