#!/bin/sh
# Set the LuCI theme and request handler once, preserving restored configuration.
set -eu

[ "$(uci -q get one-kvm-os.main.web_configured || true)" != '1' ] || exit 0
uci -q get uhttpd.main >/dev/null
uci set luci.main.mediaurlbase='/luci-static/argon'
uci set luci.main.lang='zh_cn'
uci set luci.themes.Argon='/luci-static/argon'
uci set uhttpd.main.home='/www'
uci set uhttpd.main.ubus_prefix='/ubus'
uci -q delete uhttpd.main.lua_prefix || true
uci -q delete uhttpd.main.ucode_prefix || true
uci add_list uhttpd.main.ucode_prefix='/cgi-bin/luci=/usr/share/ucode/luci/uhttpd.uc'
uci set uhttpd.main.script_timeout='600'
uci set uhttpd.main.network_timeout='600'
uci commit luci
uci commit uhttpd
uci set one-kvm-os.main.web_configured='1'
uci commit one-kvm-os
