forked from ungleich-public/cdist
[type/__uci*] Remove public-facing transaction "interface"
This commit is contained in:
parent
a6c37095f1
commit
c1ae3ccb2f
3 changed files with 10 additions and 22 deletions
|
@ -11,8 +11,6 @@ DESCRIPTION
|
|||
This cdist type can be used to alter configuration options in OpenWrt's
|
||||
Unified Configuration Interface (UCI) system.
|
||||
|
||||
Options can be applied in batches if the ``--transaction`` parameter is used.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
|
@ -30,9 +28,6 @@ OPTIONAL PARAMETERS
|
|||
-------------------
|
||||
state
|
||||
``present`` or ``absent``, defaults to ``present``.
|
||||
transaction
|
||||
The name of the transaction this option belongs to.
|
||||
If none is given: ``default`` is used.
|
||||
type
|
||||
If the type should generate an option or a list.
|
||||
One of: ``option`` or ``list``.
|
||||
|
@ -55,10 +50,10 @@ EXAMPLES
|
|||
# Set DHCP option 252: tell DHCP clients to not ask for proxy information.
|
||||
__uci dhcp.lan.dhcp_option --type list --value '252,"\n"'
|
||||
|
||||
# Enable NTP and NTPd (in one transaction)
|
||||
__uci system.ntp.enabled --value 1 --transaction ntp
|
||||
__uci system.ntp.enable_server --value 1 --transaction ntp
|
||||
__uci system.ntp.server --type list --transaction ntp \
|
||||
# Enable NTP and NTPd (each is applied individually)
|
||||
__uci system.ntp.enabled --value 1
|
||||
__uci system.ntp.enable_server --value 1
|
||||
__uci system.ntp.server --type list \
|
||||
--value '0.openwrt.pool.ntp.org' \
|
||||
--value '1.openwrt.pool.ntp.org' \
|
||||
--value '2.openwrt.pool.ntp.org' \
|
||||
|
|
|
@ -53,9 +53,6 @@ option
|
|||
shell argument.
|
||||
state
|
||||
``present`` or ``absent``, defaults to ``present``.
|
||||
transaction
|
||||
The name of the transaction this option belongs to.
|
||||
The value will be forwarded to :strong:`cdist-type__uci`\ (7).
|
||||
type
|
||||
The type of the section in the format: ``<config>.<section-type>``
|
||||
|
||||
|
@ -71,13 +68,13 @@ EXAMPLES
|
|||
.. code-block:: sh
|
||||
|
||||
# Configure the dropbear daemon
|
||||
__uci_section dropbear --type dropbear.dropbear --transaction sshd \
|
||||
__uci_section dropbear --type dropbear.dropbear \
|
||||
--match Port=22 --option Port=22 \
|
||||
--option PasswordAuth=off \
|
||||
--option RootPasswordAuth=off
|
||||
|
||||
# Define a firewall zone comprised of lan and wlan networks
|
||||
__uci_section firewall.internal --type firewall.zone --transaction fw \
|
||||
__uci_section firewall.internal --type firewall.zone \
|
||||
--option name='internal' \
|
||||
--list network='lan' \
|
||||
--list network='wlan' \
|
||||
|
@ -87,7 +84,6 @@ EXAMPLES
|
|||
|
||||
# Block SSH access from the guest network
|
||||
__uci_section firewall.block_ssh_from_guest --type firewall.rule \
|
||||
--transaction fwrules \
|
||||
--option name='Block-SSH-Access-from-Guest' \
|
||||
--option src='guest' \
|
||||
--option proto='tcp' \
|
||||
|
@ -96,7 +92,6 @@ EXAMPLES
|
|||
|
||||
# Configure a Wi-Fi access point
|
||||
__uci_section wireless.default_radio0 --type wireless.wifi-iface \
|
||||
--transaction wifi \
|
||||
--option device='radio0' \
|
||||
--option mode='ap' \
|
||||
--option network='wlan' \
|
||||
|
|
|
@ -46,7 +46,6 @@ esac
|
|||
section=$(cat "${__object:?}/explorer/match")
|
||||
|
||||
state_should=$(cat "${__object:?}/parameter/state")
|
||||
transaction_name=$(cat "${__object:?}/parameter/transaction")
|
||||
|
||||
case $state_should
|
||||
in
|
||||
|
@ -106,8 +105,7 @@ in
|
|||
fi
|
||||
|
||||
# Make sure the section itself is present
|
||||
__uci "${section}" --state present --transaction "${transaction_name}" \
|
||||
--value "${sect_type}"
|
||||
__uci "${section}" --state present --value "${sect_type}"
|
||||
export require=__uci/"${section}"
|
||||
|
||||
# Delete options/lists not in "should"
|
||||
|
@ -115,7 +113,7 @@ in
|
|||
| while read -r optname
|
||||
do
|
||||
grep_line "${optname}" "${listnames_should}" "${optnames_should}" || {
|
||||
__uci "${section}.${optname}" --state absent --transaction "${transaction_name}"
|
||||
__uci "${section}.${optname}" --state absent
|
||||
} </dev/null
|
||||
done
|
||||
|
||||
|
@ -130,14 +128,14 @@ in
|
|||
| unquote_lines \
|
||||
| append_values \
|
||||
__uci "${section}.${_optname}" --state present \
|
||||
--type "${_type}" --transaction "${transaction_name}"
|
||||
--type "${_type}"
|
||||
done
|
||||
;;
|
||||
(absent)
|
||||
# if explorer found no section there is nothing to delete
|
||||
test -n "${section}" || exit 0
|
||||
|
||||
__uci "${section}" --state absent --transaction "${transaction_name}"
|
||||
__uci "${section}" --state absent
|
||||
;;
|
||||
(*)
|
||||
printf 'Invalid --state: %s\n' "${state_should}" >&2
|
||||
|
|
Loading…
Reference in a new issue