Correct uci-defaults, how to setting samba and adguarhome?

Hi, This is my first post and im not see a welcome post. Hi to the community.

Im have a GL-MT6000 with openwrt 24.10.0. Im try to made my custom image with personal setting on the firmware selector so if im reset im have my basic setup. After read the uci-default wiki, check the change made by luci and searching on internet im thing im got it but not sure if is correct (and correct Programmable syntax) and have some question. Im try from ssh and is got working internet.

Here my script (Start with variable so im can use it for other router (GL-T3000) in the future).

Installed Packages (im add it after the default package in firmware selector):

luci-app-attendedsysupgrade
auc
luci-app-ttyd
nano
adguardhome
luci-app-sqm
kmod-usb3
kmod-usb-storage-uas
usbutils
block-mount
mount-utils
luci-app-hd-idle
luci-app-samba4

Script to run on first boot (uci-defaults)

VLAN="20"
WLAN_MAC_ADDRESS="XX:XX:XX:XX:XX:XX"
2.4G_WIFI_NAME="MY_WIFI_2.4G"
5G_WIFI_NAME="MY_WIFI_5G"
WIFI_PASSWORD="MY_WIFI_PASSWORD"

## System:
uci set system.@system[0].hostname='rtr1'

# create Vlan:
uci add network device
uci set network.@device[-1].type='8021q'
uci set network.@device[-1].ifname='eth1'
uci set network.@device[-1].vid='${VLAN}'
uci set network.@device[-1].name='eth1.20'
uci set network.@device[-1].mtu='1500'
uci set network.@device[-1].macaddr='${WLAN_MAC_ADDRESS}'
uci set network.@device[-1].ipv6='0'

# wan:
uci set network.wan.device='eth1.20'
uci set network.wan.hostname='*'
uci set network.wan.peerdns='0'
uci add_list network.wan.dns='9.9.9.9'
uci add_list network.wan.dns='149.112.112.112'

# Change DHCP:
uci set dhcp.lan.start='201'
uci set dhcp.lan.limit='48'

# Change wireless network country:
uci set wireless.radio0.country='ES'
uci set wireless.radio0.channel='auto'
uci set wireless.radio1.country='ES'
uci set wireless.radio1.channel='auto'

## Delete default wireless:
uci del wireless.default_radio0
uci del wireless.default_radio1

## Create wireless:

# Version 2.4G:
uci set wireless.wifinet0=wifi-iface
uci set wireless.wifinet0.device='radio0'
uci set wireless.wifinet0.mode='ap'
uci set wireless.wifinet0.ssid='${2.4G_WIFI_NAME}'
uci set wireless.wifinet0.encryption='sae-mixed'
uci set wireless.wifinet0.key='${WIFI_PASSWORD}'
uci set wireless.wifinet0.network='lan'

# version 5G
uci set wireless.wifinet1=wifi-iface
uci set wireless.wifinet1.device='radio1'
uci set wireless.wifinet1.mode='ap'
uci set wireless.wifinet1.ssid='${5G_WIFI_NAME}'
uci set wireless.wifinet1.encryption='sae-mixed'
uci set wireless.wifinet1.key='${WIFI_PASSWORD}'
uci set wireless.wifinet1.network='lan'

# Start Wireless:
uci del wireless.radio0.disabled
uci del wireless.radio1.disabled

## Add Static ip:
uci add dhcp host
uci set dhcp.@host[-1].name='PC1'
uci add_list dhcp.@host[-1].mac='XX:XX:XX:XX:XX:XX'
uci set dhcp.@host[-1].ip='XXX.XXX.XXX.XXX'
uci add_list dhcp.@host[-1].tag='PC'

uci add dhcp host
uci set dhcp.@host[-1].name='PC1'
uci add_list dhcp.@host[-1].mac='XX:XX:XX:XX:XX:XX'
uci add_list dhcp.@host[-1].mac='XX:XX:XX:XX:XX:XX'
uci set dhcp.@host[-1].ip='XXX.XXX.XXX.XXX'
uci add_list dhcp.@host[-1].tag='PC'

## Port Forwarding:
uci add firewall redirect
uci set firewall.@redirect[-1].dest='lan'
uci set firewall.@redirect[-1].target='DNAT'
uci set firewall.@redirect[-1].name='Torrent'
uci set firewall.@redirect[-1].src='wan'
uci set firewall.@redirect[-1].src_dport='XXXX'
uci set firewall.@redirect[-1].dest_ip='XXX.XXX.XXX.XXX'
uci set firewall.@redirect[-1].dest_port='XXXX'

uci add firewall redirect
uci set firewall.@redirect[-1].dest='lan'
uci set firewall.@redirect[-1].target='DNAT'
uci set firewall.@redirect[-1].name='Plex'
uci add_list firewall.@redirect[-1].proto='tcp'
uci set firewall.@redirect[-1].src='wan'
uci set firewall.@redirect[-1].src_dport='XXXX'
uci set firewall.@redirect[-1].dest_ip='XXX.XXX.XXX.XXX'
uci set firewall.@redirect[-1].dest_port='XXXX'

## ADGUARDHOME

#Change dnsmasq port to 54
NET_ADDR=$(/sbin/ip -o -4 addr list br-lan | awk 'NR==1{ split($4, ip_addr, "/"); print ip_addr[1]; exit }')
NET_ADDR6=$(/sbin/ip -o -6 addr list br-lan scope global | awk '$4 ~ /^fd|^fc/ { split($4, ip_addr, "/"); print ip_addr[1]; exit }')
echo "Router IPv4 : ""${NET_ADDR}"
echo "Router IPv6 : ""${NET_ADDR6}"
uci set dhcp.@dnsmasq[0].port="54"
uci set dhcp.@dnsmasq[0].domain="lan"
uci set dhcp.@dnsmasq[0].local="/lan/"
uci set dhcp.@dnsmasq[0].expandhosts="1"
uci set dhcp.@dnsmasq[0].cachesize="0"
uci set dhcp.@dnsmasq[0].noresolv="1"
uci -q del dhcp.@dnsmasq[0].server
uci -q del dhcp.lan.dhcp_option
uci -q del dhcp.lan.dns
uci add_list dhcp.lan.dhcp_option='3,'"${NET_ADDR}"
uci add_list dhcp.lan.dhcp_option='6,'"${NET_ADDR}" 
uci add_list dhcp.lan.dhcp_option='15,'"lan"
uci add_list dhcp.lan.dns="$NET_ADDR6"

# Redirect 53 traffic to router to force use of router dns:
uci add firewall redirect
uci set firewall.@redirect[-1].target='DNAT'
uci set firewall.@redirect[-1].name='DNS Interception'
uci add_list firewall.@redirect[-1].proto='udp'
uci set firewall.@redirect[-1].src='lan'
uci set firewall.@redirect[-1].src_dport='53'
uci set firewall.@redirect[-1].dest_ip='XXX.XXX.XXX.XXX'
uci set firewall.@redirect[-1].dest_port='53'

## SQM
uci del sqm.eth1.qdisc_advanced
uci del sqm.eth1.ingress_ecn
uci del sqm.eth1.egress_ecn
uci del sqm.eth1.qdisc_really_really_advanced
uci del sqm.eth1.itarget
uci del sqm.eth1.etarget
uci set sqm.eth1.enabled='1'
uci set sqm.eth1.interface='eth1.20'
uci set sqm.eth1.download='540000'
uci set sqm.eth1.upload='540000'
uci set sqm.eth1.debug_logging='0'
uci set sqm.eth1.verbosity='5'
uci set sqm.eth1.linklayer='ethernet'
uci set sqm.eth1.overhead='44'

## SAMBA
uci add samba4 sambashare
uci set samba4.@samba[-1].interface='lan'
uci set samba4.@samba[-1].description='Samba personal'

Im read is not need to add uci commit. For check if is working im try from ssh:

uci set system.@system[0].hostname='rtr1'
uci commit
reload_config

and see the change in luci.
If im do the same in luci, click save and see this change before apply see:

uci del system.cfg01e48a.timezone
uci del system.ntp.enabled
uci del system.ntp.enable_server
uci set system.cfg01e48a.hostname='rtr1'
uci set system.cfg01e48a.zonename='UTC'
uci set system.cfg01e48a.log_proto='udp'
uci set system.cfg01e48a.conloglevel='8'
uci set system.cfg01e48a.cronloglevel='7'

Question:

  • Can im just add (with the comment or not) to the firmware selector my script and is working?
  • Why luci add more line when im only change the hostname?
  • How im can create user and samba user from script (read uci is not posible but maybe with shadow-useradd)?
  • How to setup adguardhome (create adguardhome.yaml or add file from firmware selector)?

Thank you.