|
|
|
@ -8,6 +8,7 @@ import os, sys
|
|
|
|
|
import ovh
|
|
|
|
|
import requests
|
|
|
|
|
import subprocess
|
|
|
|
|
import time
|
|
|
|
|
import yaml
|
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
|
|
|
|
|
@ -34,7 +35,7 @@ client = ovh.Client(
|
|
|
|
|
|
|
|
|
|
TMPFILE = '/tmp/lastIP'
|
|
|
|
|
|
|
|
|
|
WEBRTCCONFIGFILE = `/etc/bigbluebutton/bbb-webrtc-sfu/production.yml`
|
|
|
|
|
WEBRTCCONFIGFILE = '/etc/bigbluebutton/bbb-webrtc-sfu/production.yml'
|
|
|
|
|
# WEBRTCCONFIGFILE = 'test.yml'
|
|
|
|
|
|
|
|
|
|
def get_ip():
|
|
|
|
@ -43,7 +44,7 @@ def get_ip():
|
|
|
|
|
|
|
|
|
|
def get_record_id(zone,subdomain):
|
|
|
|
|
result = client.get('/domain/zone/' + zone + '/record', fieldType='A', subDomain=subdomain )
|
|
|
|
|
# print (json.dumps(result, indent=4))
|
|
|
|
|
#print (json.dumps(result, indent=4))
|
|
|
|
|
|
|
|
|
|
return result[0]
|
|
|
|
|
|
|
|
|
@ -54,7 +55,7 @@ def set_record(zone, subdomain, ip):
|
|
|
|
|
|
|
|
|
|
if result != None:
|
|
|
|
|
my_logger.critical('couldn\'t change record')
|
|
|
|
|
exit()
|
|
|
|
|
exit(1)
|
|
|
|
|
|
|
|
|
|
result = client.post('/domain/zone/' + zone + '/refresh')
|
|
|
|
|
return result
|
|
|
|
@ -82,7 +83,7 @@ if len(sys.argv) > 2:
|
|
|
|
|
|
|
|
|
|
if lastIP == currentIP:
|
|
|
|
|
my_logger.debug ('IP has not changed since last call')
|
|
|
|
|
exit()
|
|
|
|
|
exit(1)
|
|
|
|
|
|
|
|
|
|
if (set_record (sys.argv[1], sys.argv[2], currentIP) == None ):
|
|
|
|
|
write_config_file(currentIP)
|
|
|
|
@ -94,8 +95,6 @@ if len(sys.argv) > 2:
|
|
|
|
|
else:
|
|
|
|
|
my_logger.critical('Couldn\'t change IP')
|
|
|
|
|
|
|
|
|
|
with open(TMPFILE, 'w') as file:
|
|
|
|
|
file.write(currentIP)
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
print('Updates IP record of SUBDOMAIN in ZONE to current IP from ipinfo.io\n\nUsage:\n' + sys.argv[0] + ' ZONE SUBDOMAIN')
|
|
|
|
|