Skip to content

Commit 85b95b8

Browse files
miniupnpd: rename UCI section name to settings (v2.0)
Inspired/address copilot's PR review for a clearer config by rename UCI section name `config` (v1.0) -> `settings` (v2.0), helps on migration and to distinguish the updated config from the previous one easily (to merge with prior) Signed-off-by: Self-Hosting-Group <[email protected]>
1 parent 6fc4898 commit 85b95b8

File tree

5 files changed

+38
-31
lines changed

5 files changed

+38
-31
lines changed

net/miniupnpd/files/firewall3.include

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ add_extzone_rules() {
4848

4949
# By default, user configuration is king.
5050

51-
for ext_iface in $(uci -q get upnpd.config.external_iface); do
51+
for ext_iface in $(uci -q get upnpd.settings.external_iface); do
5252
add_extzone_rules $(fw3 -q network "$ext_iface")
5353
done
5454

55-
add_extzone_rules $(uci -q get upnpd.config.external_zone)
55+
add_extzone_rules $(uci -q get upnpd.settings.external_zone)
5656

5757
[ "$ADDED" -ne 0 ] && exit 0
5858

net/miniupnpd/files/miniupnpd.hotplug

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
[ "$ACTION" != "ifup" ] && /etc/init.d/miniupnpd running && exit 0
1111

1212
tmpconf="/var/etc/miniupnpd.conf"
13-
external_iface=$(uci -q get upnpd.config.external_iface)
14-
external_iface6=$(uci -q get upnpd.config.external_iface6)
15-
external_zone=$(uci -q get upnpd.config.external_zone)
13+
external_iface=$(uci -q get upnpd.settings.external_iface)
14+
external_iface6=$(uci -q get upnpd.settings.external_iface6)
15+
external_zone=$(uci -q get upnpd.settings.external_zone)
1616
[ -x "$(command -v nft)" ] && FW="fw4" || FW="fw3"
1717

1818
. /lib/functions/network.sh

net/miniupnpd/files/miniupnpd.init

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,42 +40,42 @@ upnpd_add_custom_acl_entry() {
4040
upnpd() {
4141
config_load "upnpd"
4242
local enabled
43-
config_get enabled config enabled 0
43+
config_get enabled settings enabled 0
4444
if [ "$enabled" != "1" ]; then
4545
log "Service disabled, UCI enabled is not set"
4646
return 1
4747
fi
4848
# Daemon
4949
local enabled_protocols allow_cgnat stun_host allow_third_party_mapping ipv6_disable system_uptime log_output lease_file config_file
50-
config_get enabled_protocols config enabled_protocols all
51-
config_get allow_cgnat config allow_cgnat 0
52-
config_get stun_host config stun_host stun.nextcloud.com
53-
config_get allow_third_party_mapping config allow_third_party_mapping 0
54-
config_get ipv6_disable config ipv6_disable 0
55-
config_get system_uptime config system_uptime 1
56-
config_get log_output config log_output
57-
config_get lease_file config lease_file /run/miniupnpd.leases
58-
config_get config_file config config_file
50+
config_get enabled_protocols settings enabled_protocols all
51+
config_get allow_cgnat settings allow_cgnat 0
52+
config_get stun_host settings stun_host stun.nextcloud.com
53+
config_get allow_third_party_mapping settings allow_third_party_mapping 0
54+
config_get ipv6_disable settings ipv6_disable 0
55+
config_get system_uptime settings system_uptime 1
56+
config_get log_output settings log_output
57+
config_get lease_file settings lease_file /run/miniupnpd.leases
58+
config_get config_file settings config_file
5959

6060
# UPnP IGD
6161
local upnp_igd_compat download_kbps upload_kbps friendly_name model_number serial_number presentation_url uuid http_port notify_interval
62-
config_get upnp_igd_compat config upnp_igd_compat igdv1
63-
config_get download_kbps config download_kbps
64-
config_get upload_kbps config upload_kbps
65-
config_get friendly_name config friendly_name "OpenWrt UPnP IGD & PCP"
66-
config_get model_number config model_number
67-
config_get serial_number config serial_number
68-
config_get presentation_url config presentation_url
69-
config_get uuid config uuid
70-
config_get http_port config http_port 5000
71-
config_get notify_interval config notify_interval
62+
config_get upnp_igd_compat settings upnp_igd_compat igdv1
63+
config_get download_kbps settings download_kbps
64+
config_get upload_kbps settings upload_kbps
65+
config_get friendly_name settings friendly_name "OpenWrt UPnP IGD & PCP"
66+
config_get model_number settings model_number
67+
config_get serial_number settings serial_number
68+
config_get presentation_url settings presentation_url
69+
config_get uuid settings uuid
70+
config_get http_port settings http_port 5000
71+
config_get notify_interval settings notify_interval
7272

7373
# External network interface
7474
local external_iface external_iface6 external_zone external_ip
75-
config_get external_iface config external_iface
76-
config_get external_iface6 config external_iface6
77-
config_get external_zone config external_zone
78-
config_get external_ip config external_ip
75+
config_get external_iface settings external_iface
76+
config_get external_iface6 settings external_iface6
77+
config_get external_zone settings external_zone
78+
config_get external_ip settings external_ip
7979

8080
local conf ifname ifname6
8181
. /lib/functions/network.sh
@@ -155,7 +155,7 @@ upnpd() {
155155
[ -z "$uuid" ] && {
156156
log "Generate UPnP IGD UUID"
157157
uuid="$(cat /proc/sys/kernel/random/uuid)"
158-
uci set upnpd.config.uuid="$uuid"
158+
uci set upnpd.settings.uuid="$uuid"
159159
uci commit upnpd
160160
}
161161
[ "$uuid" != "nocli" ] && echo "uuid=$uuid" || log "Deprecated. Set uuid to 00000000-0000-0000-0000-000000000000 instead"

net/miniupnpd/files/upnpd-migration.uci-defaults

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ log() {
44
logger -s -p "${2:-daemon.notice}" -t "upnpd" "$1" || echo "upnpd: $1" >&2
55
}
66

7+
{ uci -q get upnpd.settings >/dev/null || ! uci -q get upnpd.config >/dev/null; } && exit 0
78
log "Check UCI options in /etc/config/upnpd to be migrated to v2.0"
89

910
# Set missing enabled option to fix previously different defaults in LuCI/config (0) and init UCI (1)
@@ -232,6 +233,12 @@ if ! uci -q get upnpd.@internal_network[0] >/dev/null; then
232233
uci -q delete upnpd.config.internal_iface
233234
fi
234235

236+
# Finally rename section config -> settings (v2.0)
237+
if uci -q get upnpd.config >/dev/null; then
238+
log "Rename section config -> settings (v2.0)" && uci rename upnpd.config="settings" ||
239+
log "Error renaming the UCI section" daemon.err
240+
fi
241+
235242
uci commit upnpd >/dev/null
236243

237244
exit 0

net/miniupnpd/files/upnpd.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# UPnP IGD & PCP/NAT-PMP Service Settings (v2.0)
22

3-
config upnpd 'config'
3+
config upnpd 'settings'
44
option enabled '0'
55
# Can be set to all/upnp-igd/pcp+nat-pmp
66
option enabled_protocols 'all'

0 commit comments

Comments
 (0)