#!/bin/sh

# check if this is a new type UCI or old type UCI
if ! uci -q get logmngr.default_source > /dev/null; then
	uci -q set logmngr.default_source=source
	uci -q set logmngr.default_source.name='default_source'
	uci -q set logmngr.default_source.system_messages='1'
	uci -q set logmngr.default_source.kernel_messages='1'
fi

if ! uci -q get logmngr.default_template > /dev/null; then
	uci -q set logmngr.default_template=template
	uci -q set logmngr.default_template.name='default_template'
	uci -q set logmngr.default_template.expression='{time} {hostname} {ident}[{pid}]: {message}'
fi

if uci -q get logmngr.a1 >/dev/null; then
	uci -q rename logmngr.a1='default_action'
	uci -q set logmngr.default_action.name='default_action'
	uci -q set logmngr.default_action.template='default_template'

	uci -q delete logmngr.default_action.source
	uci -q add_list logmngr.default_action.source='default_source'
fi

if uci -q get logmngr.lf1 >/dev/null; then
	uci -q rename logmngr.lf1='default_logfile'
	uci -q set logmngr.default_logfile.action='default_action'
fi

if uci -q get logmngr.lr1 >/dev/null; then
	uci -q rename logmngr.lr1='default_logremote'
	uci -q set logmngr.default_logremote.action='default_action'
fi

exit 0
