#!/usr/bin/python3

from configparser import RawConfigParser

from univention.appcenter.log import log_to_stream
from univention.appcenter.actions import get_action
from univention.appcenter.app_cache import Apps
from univention.appcenter.ucr import ucr_save

log_to_stream()


update = get_action('update')
update.call()

app = Apps().find('seafile')

print('Changing default settings for', app)
parser = RawConfigParser()
with open(app.get_cache_file('settings'), 'r') as f:
	parser.read_file(f)
	parser.set('SEAFILE_ADMIN_PASSWORD', 'InitialValue', 'secret-password123')
	parser.set('SEAFILE_ADMIN_EMAIL', 'InitialValue', 'admin@example.com')

with open(app.get_cache_file('settings'), 'w') as f:
	parser.write(f)

Apps().clear_cache()
ucr_save({'appcenter/umc/update/always': 'false'})