From d05896738992dc04676663222a250177d2294364 Mon Sep 17 00:00:00 2001 From: yova Date: Mon, 29 Aug 2022 22:19:45 +0000 Subject: [PATCH] make bbb restart work --- dyndns-update.py | 11 +++++------ readme.md | 10 +++++++--- update-bbb.sh | 3 +++ 3 files changed, 15 insertions(+), 9 deletions(-) create mode 100755 update-bbb.sh diff --git a/dyndns-update.py b/dyndns-update.py index 991ceb1..13f028b 100755 --- a/dyndns-update.py +++ b/dyndns-update.py @@ -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') diff --git a/readme.md b/readme.md index c769c13..b522922 100644 --- a/readme.md +++ b/readme.md @@ -24,18 +24,22 @@ and edit `.env` with credentials from https://www.ovh.com/auth/api/createToken `dyndns-update ZONE SUBDOMAIN` +Returns 0 if IP change happened, 1 otherwise. + +Use bbb-update.sh to configure domain for cronjobs or so to also restart bbb. + ## install For changing the loopback device IP, this needs root rights. ``` -cd /root +cd ~ git clone git@git.gugelfrei.de:bbb/dyndns-update.git ``` -Install as user cronjob like +Install as cronjob like -`*/5 * * * * cd /root/dyndns-update ; ./dyndns-update.py ZONE SUBDOMAIN` +`*/5 * * * * root cd /home/user/dyndns-update ; ./update-bbb.sh` to `/etc/cron.d/bbb` diff --git a/update-bbb.sh b/update-bbb.sh new file mode 100755 index 0000000..10f1ed3 --- /dev/null +++ b/update-bbb.sh @@ -0,0 +1,3 @@ +#!/usr/bin/sh +./dyndns-update.py joefix.it op +[ $? -eq 0 ] && sleep 10 && bbb-conf --restart