Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions board/common/rootfs/etc/finit.d/available/ptp4l@.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
service <!> name:ptp4l :%i log:prio:daemon,tag:ptp4l-%i \
[2345] ptp4l -f /etc/linuxptp/ptp4l-%i.conf \
service <!> name:ptp4l :%i log:prio:daemon,tag:ptp4l-%i env:-/etc/default/ptp4l \
[2345] ptp4l -f /etc/linuxptp/ptp4l-%i.conf $PTP4L_ARGS \
-- PTP instance %i
16 changes: 16 additions & 0 deletions board/common/rootfs/usr/bin/askline
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh
# Prompt for a single-line value, prefilled with the current one.
#
# askline LABEL FILE
#
# FILE holds the current value on entry and the new value on exit.
# shellcheck disable=SC3045

LABEL=$1
FILE=$2

current=$(cat "$FILE" 2>/dev/null)
read -er -p "$LABEL> " -i "$current" value || exit 1

umask 0177
printf '%s' "$value" > "$FILE"
62 changes: 62 additions & 0 deletions board/common/rootfs/usr/bin/datetime
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/sh
# Set system date and time via the set-current-datetime RPC.
#
# datetime [-e] [VALUE]
#
# With -e the current time is offered for editing in a prompt. VALUE
# is converted to the ISO-8601 format required by the RPC, and the
# result is echoed before setting so mistakes are easy to spot.

usage()
{
cat >&2 <<EOT
Usage: datetime [-e] [VALUE]

VALUE is local time unless a zone is given:
2026-09-09T14:05:00+02:00 ISO-8601, as used by NETCONF/RESTCONF
2026-09-09T14:05:00 same, local time
2026-09-09 14:05[:00]
2026-09-09 midnight
14:05[:00] today
09.09-14:05 mm.dd-HH:MM, this year
EOT
exit 1
}

edit=
if [ "$1" = "-e" ]; then
edit=1
shift
fi
value=$1

if [ -n "$edit" ]; then
tmp=$(mktemp) || exit 1
date -Isec > "$tmp"
if ! askline datetime "$tmp"; then
rm -f "$tmp"
exit 1
fi
value=$(cat "$tmp")
rm -f "$tmp"
fi
[ -n "$value" ] || usage

case $value in
[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9]Z | \
[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9][+-][0-9][0-9]:[0-9][0-9])
iso=$value
;;
*)
# Let date(1) parse anything else as local time, it does not
# know the ISO-8601 'T' separator.
plain=$(printf '%s' "$value" | sed 's/T/ /')
if ! iso=$(date -d "$plain" -Isec 2>/dev/null); then
echo "Cannot parse '$value'" >&2
usage
fi
;;
esac

echo "Setting datetime $iso"
exec rpc /ietf-system:set-current-datetime current-datetime "$iso"
19 changes: 19 additions & 0 deletions doc/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,25 @@ All notable changes to the project are documented in this file.
- Add per-server `minpoll` and `maxpoll` options to the NTP client
configuration, for tuning how often each server is polled

### Added

- Add `/system/advanced` for low-level system customization, issue #463:
- `rc.d`: user scripts stored in the configuration, run once at boot
after the startup configuration has been applied, in the order listed
- `default`: daemon environment files written to `/etc/default`, e.g.,
extra `ptp4l` command line options
- The CLI `edit` command now also edits settings interactively: passwords
and keys are prompted for, `binary` settings open in the text editor, and
`string` settings are edited on a line prefilled with the current value.
The `text-editor` and `change` commands are removed
- Add CLI `edit` and `clear` verbs to admin-exec: `edit datetime` and
`edit boot-order` prompt with the current value, `clear dhcp-server
statistics` replaces `dhcp-server clear-statistics`. `set datetime` now
also accepts free-form input, e.g., `14:05`, and echoes the ISO-8601
value it sets
- The CLI `configure` command takes an optional path to start in a
sub-context directly, e.g., `configure system authentication`

[v26.08.0][] - 2026-09-01
-------------------------

Expand Down
6 changes: 2 additions & 4 deletions doc/cli/configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ admin@host:/config/>
delete Delete configuration setting(s)
diff Summarize uncommitted changes
do Execute operational mode command
edit Descend to the specified configuration node
edit Descend to configuration node, or edit a setting interactively
end Alias to up, leave this subsection/node
exit Ascend to the parent configuration node, or abort (from top)
leave Finalize candidate and apply to running-config
no Alias for delete
rollback Restore candidate to running-config
set Set configuration setting
show Show configuration
text-editor Modify binary content in a text editor
top Ascend to the configuration root
up Ascend to the parent configuration node
```
Expand Down Expand Up @@ -179,8 +178,7 @@ admin@host:/config/system/authentication/user/admin/authorized-key/example@host/
> **Note**
>
> The `ssh-keygen` program already base64 encodes the public key data,
> so there is no need to use the `text-editor` command, `set` does the
> job.
> so there is no need to use the `edit` command, `set` does the job.

----

Expand Down
15 changes: 12 additions & 3 deletions doc/cli/text-editor.md → doc/cli/edit.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
# Text Editor
# Edit Command

The CLI built-in `text-editor` command can be used to edit type `binary`
settings in configure context.
In configure context, `edit` descends into a container or list entry,
e.g., `edit interface eth0`. Used on a setting it instead modifies the
current value interactively, depending on the type of setting:

- passwords and keys: prompt without echo, with confirmation
- `binary` settings: open the built-in text editor, e.g., `edit content`
in a boot script, or `edit motd-banner`
- `string` settings: prompt on a single line prefilled with the current
value, use the arrow keys to move around and Enter to accept

Other types are set with `set`.

The default editor is a Micro Emacs clone. Users not familiar with
terminal based editors may benefit from this introduction.
Expand Down
9 changes: 7 additions & 2 deletions doc/cli/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ Available commands can be seen by pressing `?` at the prompt:

```
admin@host:/>
clear Clear runtime state, e.g., statistics
configure Create new candidate-config based on running-config
copy Copy file or configuration, e.g., copy running-config startup-config
dir List available configuration files
edit Edit system state interactively, e.g., current date/time
exit Exit from CLI (log out)
factory-reset Restore the system to factory default state
follow Monitor a log file, use Ctrl-C to abort
Expand Down Expand Up @@ -96,6 +98,9 @@ admin@host-12-34-56:/config/> ... # Try: Tab or ?
admin@host-12-34-56:/config/> leave
```

The `configure` command also takes an optional path, to start out in a
sub-context directly, e.g., `configure system authentication`.

The `leave` command activates the changes by issuing a transaction to,
essentially, copy the *candidate* back to *running*. Depending on the
changes made, this can take a few seconds. If the changes are invalid,
Expand All @@ -119,8 +124,8 @@ In *configure context* the following commands are available:
| `set foo bar val` | Set `bar` leaf node in `foo` subcontext to `val` |
| `no foo bar` | Clear/delete configuration made to `bar` in `foo` |
| `edit foo baz` | Enter `baz` sub-sub-context in `foo` subcontext |
| `change password` | Start password dialogue to change a user's password |
| `text-editor foo` | Open a text editor to edit binary setting `foo` |
| `edit password` | Start password dialogue to change a user's password |
| `edit foo` | Edit setting `foo` interactively, see `help edit` |
| `abort` | Abort changes in configuration, return to admin-exec |
| `exit` | Exit one level sub-context, or abort from top-level |
| `leave` | Save changes to `running-config`, return to admin-exec |
Expand Down
4 changes: 2 additions & 2 deletions doc/cli/quick.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ keybindings are really useful to learn!
|---------------------|----------------------------------------------------|
| `help introduction` | An introduction to the CLI |
| `help configure` | How to use configure context |
| `help text-editor` | Help with the built-in text-editor command |
| `help edit` | Editing settings interactively, incl. text editor |
| `help keybindings` | Lists available keybindings & other helpful tricks |

> **Tip:** Online Help
>
> In `configure` context the `help <setting>` command shows the YANG
> description text for each node and container. To reach the admin
> exec help from configure context, e.g., `do help text-editor`
> exec help from configure context, e.g., `do help edit`
8 changes: 4 additions & 4 deletions doc/container.md
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ its `startup-config` (or even `factory-config`) a temporary file is
created using the decoded base64 data from the `content` node.

<pre class="cli"><code>admin@example:/config/container/ntpd/> <b>edit mount ntpd.conf</b>
admin@example:/config/container/ntpd/mount/ntpd.conf> <b>text-editor content</b>
admin@example:/config/container/ntpd/mount/ntpd.conf> <b>edit content</b>
... interactive editor starts up ...
admin@example:/config/container/ntpd/mount/ntpd.conf> <b>set target /etc/ntpd.conf</b>
admin@example:/config/container/ntpd/mount/ntpd.conf> <b>end</b>
Expand All @@ -888,7 +888,7 @@ the contents are base64 encoded and stored in the candidate datastore.
> host's startup-config.

Infix has three different text editors available. For more information,
see [CLI Text Editor](cli/text-editor.md).
see the [CLI edit command](cli/edit.md).


Example Containers
Expand Down Expand Up @@ -975,7 +975,7 @@ admin@example:/config/container/nftables/> <b>set network host</b>
admin@example:/config/container/nftables/> <b>set privileged</b>
admin@example:/config/container/nftables/> <b>edit mount nftables.conf</b>
admin@example:/config/…/mount/nftables.conf/> <b>set target /etc/nftables.conf</b>
admin@example:/config/…/mount/nftables.conf/> <b>text-editor content</b>
admin@example:/config/…/mount/nftables.conf/> <b>edit content</b>
... interactive editor starts up where you can paste your rules ...
admin@example:/config/…/mount/nftables.conf/> <b>leave</b>
</code></pre>
Expand Down Expand Up @@ -1003,7 +1003,7 @@ admin@example:/config/container/ntpd/> <b>set image ghcr.io/kernelkit/curios-ntp
admin@example:/config/container/ntpd/> <b>set network interface ntpd</b> # From veth0 above
admin@example:/config/container/ntpd/> <b>edit mount ntp.conf</b>
admin@example:/config/container/ntpd/mount/ntp.conf/> <b>set target /etc/ntp.conf</b>
admin@example:/config/container/ntpd/mount/ntp.conf/> <b>text-editor content</b>
admin@example:/config/container/ntpd/mount/ntp.conf/> <b>edit content</b>
... interactive editor starts up where you can paste your rules ...
admin@example:/config/container/ntpd/mount/ntp.conf/> <b>end</b>
admin@example:/config/container/ntpd/> <b>edit volume varlib</b>
Expand Down
6 changes: 3 additions & 3 deletions doc/scripting-sysrepocfg.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,9 @@ on interface *e0*.

A YANG `binary` type setting is Base64 encoded and requires a little bit
more tricks. We take the opportunity to showcase a shell script helper:
`/usr/bin/text-editor`, which works just like the `text-editor` command
in the CLI, but this one takes an XPath argument to the binary leaf to
edit.
`/usr/bin/text-editor`, which works just like the `edit` command in the
CLI does for a `binary` setting, but this one takes an XPath argument to
the leaf to edit.

Stripped down, it looks something like this:

Expand Down
79 changes: 73 additions & 6 deletions doc/system.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ admin@example:/config/system/…/example@host/> <b>leave</b>

> [!NOTE]
> The `ssh-keygen` program already base64 encodes the public key data,
> so there is no need to use the `text-editor` command, `set` does the
> job.
> so there is no need to use the `edit` command, `set` does the job.

## Multiple Users

Expand Down Expand Up @@ -394,15 +393,15 @@ to clients, it is up to the clients to request the domain name *option*.
## Changing Login Banner

The `motd-banner` setting is an Infix augment and an example of a
`binary` type setting that can be changed interactively with the
built-in [`text-editor` command](cli/text-editor.md).
`binary` type setting that is changed interactively with the built-in
[`edit` command](cli/edit.md).

> [!TIP]
> See the next section for how to change the editor used to something
> you may be more familiar with.

<pre class="cli"><code>admin@example:/config/> <b>edit system</b>
admin@example:/config/system/> <b>text-editor motd-banner</b>
admin@example:/config/system/> <b>edit motd-banner</b>
admin@example:/config/system/> <b>leave</b>
admin@example:/>
</code></pre>
Expand All @@ -413,7 +412,7 @@ Log out and log back in again to inspect the changes.
## Changing the Editor

The system has three different built-in editors that can be used
as the `text-editor` command:
by the `edit` command:

- `emacs` (Micro Emacs)
- `nano` (GNU Nano)
Expand Down Expand Up @@ -546,6 +545,74 @@ reference ID, stratum, time offsets, frequency, and root delay.
> The system uses `chronyd` Network Time Protocol (NTP) daemon. The
> output shown here is best explained in the [Chrony documentation][4].

## Boot Scripts

For debugging and development it is sometimes useful to run a custom
script every time the system boots, e.g., to put a hardware component
in test mode, or to start a data collector for a transient problem.
Such scripts can be stored in the configuration under
`/system/advanced/rc.ds`, so that everything that runs on the system can
be traced back to the `startup-config`.

Scripts are run once at boot, as `root`, one at a time, in the order
listed, after the startup configuration has been applied. A script
without a `#!` interpreter line is run by `/bin/sh`. Output and exit
status are logged to the system log, see `show log`. Changes to the
scripts only take effect at the next boot.

> [!TIP]
> Individual scripts can be disabled, e.g., to keep a script around
> without running it.

The script contents is a `binary` type setting, so like the [login
banner](#changing-login-banner) it is edited with the built-in
[`edit` command](cli/edit.md):

<pre class="cli"><code>admin@example:/> <b>configure</b>
admin@example:/config/> <b>edit system advanced rc.d phy-test</b>
admin@example:/config/system/advanced/rc.d/phy-test/> <b>set description "Put PHY in test mode"</b>
admin@example:/config/system/advanced/rc.d/phy-test/> <b>edit content</b>
admin@example:/config/system/advanced/rc.d/phy-test/> <b>leave</b>
admin@example:/> <b>copy running-config startup-config</b>
admin@example:/> <b>reboot</b>
</code></pre>

> [!NOTE]
> The CLI has no command to reorder scripts. A new script is always
> added last, so to change the order, delete a script and add it again.
> Alternatively, edit `/cfg/startup-config.cfg` from a shell and
> reboot. The WebUI supports reordering scripts by drag-and-drop.


## Daemon Default Files

Most system daemons source an environment file, `/etc/default/NAME`,
at startup for extra command line options, e.g., `PTP4L_ARGS` in
`/etc/default/ptp4l`. Such files can be stored in the configuration
under `/system/advanced/defaults`, to tune daemon behavior beyond what
the rest of the configuration exposes. For example, to force PTP minor
version 0 for a NIC that does not support anything else:

<pre class="cli"><code>admin@example:/> <b>configure</b>
admin@example:/config/> <b>edit system advanced default ptp4l</b>
admin@example:/config/system/advanced/default/ptp4l/> <b>set description "Intel NIC only speaks PTP v2.0"</b>
admin@example:/config/system/advanced/default/ptp4l/> <b>edit content</b>
... enter PTP4L_ARGS="--ptp_minor_version 0" and save ...
admin@example:/config/system/advanced/default/ptp4l/> <b>leave</b>
</code></pre>

The file is written when the configuration is activated, and a system
service with the same name is restarted if its environment changed. A
file that shadows one shipped with the system is restored when the
entry is disabled or removed.

> [!WARNING]
> These files are applied as-is. A bad setting can prevent a daemon
> from starting, and the configuration may then be lost at next boot if
> the system falls back to its fail-secure mode. Always test with
> `copy running-config startup-config` deferred until verified.


[1]: https://www.rfc-editor.org/rfc/rfc7317
[2]: https://github.com/kernelkit/infix/blob/main/src/confd/yang/infix-system%402024-02-29.yang
[3]: https://www.rfc-editor.org/rfc/rfc8341
Expand Down
4 changes: 2 additions & 2 deletions package/confd/confd.mk
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ else
CONFD_CONF_OPTS += --disable-webui
endif
define CONFD_INSTALL_EXTRA
for fn in confd.conf crond.conf resolvconf.conf; do \
for fn in confd.conf crond.conf rcd.conf resolvconf.conf; do \
cp $(CONFD_PKGDIR)/$$fn $(FINIT_D)/available/; \
done
for fn in confd.conf resolvconf.conf; do \
for fn in confd.conf rcd.conf resolvconf.conf; do \
ln -sf ../available/$$fn $(FINIT_D)/enabled/$$fn; \
done
cp $(CONFD_PKGDIR)/tmpfiles.conf $(TARGET_DIR)/etc/tmpfiles.d/confd.conf
Expand Down
4 changes: 4 additions & 0 deletions package/confd/rcd.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Run user scripts from /etc/rc.d once at boot, after the startup
# configuration has been applied, see /system/advanced/rc.d
task [2345] name:rcd log <usr/bootstrap> \
/usr/libexec/finit/runparts -bp /etc/rc.d -- Running rc.d scripts
2 changes: 1 addition & 1 deletion package/klish-plugin-sysrepo/klish-plugin-sysrepo.hash
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Locally calculated
sha256 9d9d33b873917ca5d0bdcc47a36d2fd385971ab0c045d1472fcadf95ee5bcf5b LICENCE
sha256 7bfdaef838ee8bd3995140c40144abe79ff1c6391c7b48445e6728cd4e7e56a8 klish-plugin-sysrepo-2f14503c7ea6eb24c8adaf0cf2cf7a511114b09e-git4.tar.gz
sha256 0c07cb330a9f3855eefe9f9fa0d9f91d921cbf369571e943ab9ac264cd281db0 klish-plugin-sysrepo-3b4e69780e64f0b8f42dc3784defe72285911ad4-git4.tar.gz
Loading
Loading