#! /usr/bin/python3

import os
import configparser

CONFIG_FILE=os.environ['SNAP_DATA'] + '/config'
KEYS=['updateipv4', 'updateipv6', 'domain', 'password', 'ipv4hostname', 'ipv6hostname']

config = configparser.ConfigParser()
config.read(CONFIG_FILE)

for key in KEYS:
    value = os.popen('snapctl get ' + key).read()
    config.set('User', key, value)

with open(CONFIG_FILE, 'w') as configfile:
    config.write(configfile)