diff --git a/README.md b/README.md index fccf08f..c5dd55b 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,14 @@ ## Prerequisite -`NAMESILO_API` in environment variable +`NAMESILO_API` in environment variable or in `settings.conf` `settings.conf` in the same directory [default] domain=example.com subdomain=dynamic +namesilo_api=SECRET_KEY ### Python3 library diff --git a/update.py b/update.py index 960daf3..7cfa486 100644 --- a/update.py +++ b/update.py @@ -62,15 +62,17 @@ def update_namesilo_data(key, domain, rrid, subdomain, new_value): 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.read('settings.conf') domain = config['default']['domain'] 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) print('TARGET: {}'.format(target)) public_ip = get_public_ip()