Browse Source

namesilo_api can also be set in settings.conf

pull/1/head
sipp11 5 years ago
parent
commit
5552563405
  1. 3
      README.md
  2. 12
      update.py

3
README.md

@ -2,13 +2,14 @@
## Prerequisite ## Prerequisite
`NAMESILO_API` in environment variable `NAMESILO_API` in environment variable or in `settings.conf`
`settings.conf` in the same directory `settings.conf` in the same directory
[default] [default]
domain=example.com domain=example.com
subdomain=dynamic subdomain=dynamic
namesilo_api=SECRET_KEY
### Python3 library ### Python3 library

12
update.py

@ -62,15 +62,17 @@ def update_namesilo_data(key, domain, rrid, subdomain, new_value):
def main(): def main():
api_key = os.environ['NAMESILO_API']
if not api_key:
print('NAMESILO_API in env is not found.')
sys.exit()
print('KEY: {}...'.format(api_key[:3]))
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read('settings.conf') config.read('settings.conf')
domain = config['default']['domain'] domain = config['default']['domain']
subdomain = config['default']['subdomain'] subdomain = config['default']['subdomain']
api_key = os.environ.get('NAMESILO_API', None)
if not api_key:
if 'namesilo_api' not in config['default']:
print('NAMESILO_API not found.')
sys.exit()
api_key = config['default']['namesilo_api']
print('KEY: {}...'.format(api_key[:3]))
target = '{}.{}'.format(subdomain, domain) target = '{}.{}'.format(subdomain, domain)
print('TARGET: {}'.format(target)) print('TARGET: {}'.format(target))
public_ip = get_public_ip() public_ip = get_public_ip()

Loading…
Cancel
Save