#!/usr/bin/python3

# System Imports
from os import execvp
from os import getpid
from pathlib import PurePath
from urllib.request import urlretrieve

# Local Imports
from includes.python_logger import create_logger

def main():
  logger = create_logger(PurePath(__file__).stem)

  logger.info('Beginning root hint file download')

  url = 'https://www.internic.net/domain/named.cache'
  urlretrieve(url, '/etc/unbound/root.hints')

  logger.info(f'Starting tini as pid {getpid()}')
  execvp('tini', ['tini', '-e',  '143', '--', '/usr/sbin/unbound', '-d', '-d', '-c', '/etc/unbound/unbound.conf'])

if __name__ == "__main__":
  main()
