#!/bin/sh

changed=0

set_opt() {
	local key=$1
	local val=$2

	if ! uci -q get "luci.$key" 2>/dev/null; then
		uci set "luci.$key=$val"
		changed=1
	fi
}

set_opt themes.Material3 /luci-static/material3

if [ "$PKG_UPGRADE" != 1 ] && [ $changed = 1 ]; then
	set_opt main.mediaurlbase /luci-static/material3
fi

# set_opt themes.Material3Dark /luci-static/material3-dark
# set_opt themes.Material3Light /luci-static/material3-light
set_opt themes.Material3Blue /luci-static/material3-blue
set_opt themes.Material3Green /luci-static/material3-green
set_opt themes.Material3Red /luci-static/material3-red

if [ $changed = 1 ]; then
	uci commit luci
fi

exit 0
