SliTaz system administration backend
Trame is one command, trame, with sub-commands to set up a
SliTaz system: host name, services, clock, network, Wi-Fi, Bluetooth,
locale, users, disks, kernel, boot menu, power, screens, sound,
firewall, keyboard, hardware and printers. It is a POSIX shell script
on top of busybox, with one library file per sub-command.
The same commands serve everyone. In a terminal, Trame prints short
aligned text. With --json, it prints stable JSON that the
SliTaz graphical tools and panels (TazPanel, the trame-gui, the
ncurses front-end trame-tui) and the Wove assistant read
instead of running Unix tools themselves. Every change is checked first,
is idempotent (asking for the current state changes nothing) and is
written to a log.
This manual covers Trame 1.2.21.
- Install and requirements
- Universal options
- system
- hostname
- service
- time
- network
- wifi
- bluetooth
- locale
- log
- user
- storage
- kernel
- boot
- power
- display
- audio
- firewall
- keyboard
- hardware
- printer
- Configuration and environment
- JSON output and exit codes
- Hooks
- About
Install and requirements
Trame is part of the SliTaz 5.1 images (i486 and x86_64): nothing to
install. From the sources, make install installs into
$DESTDIR$PREFIX (default /usr) and
make test runs the test suite.
| File | Role |
|---|---|
/usr/bin/trame | The command |
/usr/lib/slitaz/trame/ | common.sh
and one trame-<command>.sh per sub-command |
/usr/share/trame/schemas/ | JSON schema of each sub-command |
/etc/slitaz/trame.conf | Configuration |
/etc/slitaz/trame.d/hooks/ | Optional hooks |
/var/log/trame.log | Log of every change |
Trame needs only busybox. Optional parts are detected, never assumed:
when a tool is missing, the error says what to install, for example
iptables not installed (run: spk-add iptables). Bluetooth
needs the trame-bluetooth package (bluez and the
trame-bt helper), printing through CUPS needs
cups.
Reading is open to every user. Changes need root: run them with
sudo trame ... or as root. A user may still preview any
change with --dry-run or --explain, which are
checked before root is required. A few changes that belong to the
user's own session (screen layout, Bluetooth files, printing a file)
run without root; each section says which.
Universal options
trame <command> <action> [args] [--options]
Options may come anywhere on the line. An unknown --option
is refused with exit code 1.
| --json | Print JSON on stdout (errors as JSON on stderr). |
| --dry-run | Say what would change, change nothing. |
| --explain | Print as JSON the commands Trame would run, change nothing. |
| --schema | Print the JSON schema of the sub-command. |
| --yes | Confirm a destructive action
(firewall flush, power reboot,
power poweroff). |
| --quiet | Nothing on stdout on success: the exit code only. |
| -h, --help | Help. trame <command>
alone prints the actions of that command. |
--dry-run and --explain only apply to changes:
on a read-only action (list, get, status...) they are an error.
Introspection, for scripts and front-ends:
| trame --version | Print the version. |
| trame --list-commands | One sub-command per line; with
--json, names and descriptions. |
| trame --schemas | Every schema as one JSON array. |
$ trame hostname set myhost --dry-run Would set hostname: slitaz -> myhost $ trame hostname set myhost --explain # trame hostname set myhost --json
system
Read-only information about the computer.
| info | Distribution, computer model, CPU, memory, swap, host name, kernel, arch, number of packages, uptime. |
| kernel | Kernel version, arch, loaded modules count. |
| uptime | Uptime and load average. |
| report [file] | Write a support report to share on the
forum: the output of the read-only Trame commands, the kernel
command line, modules, kernel errors, Xorg errors and the end of
boot.log. No password, no Wi-Fi key, no access point
address. Default file:
/tmp/slitaz-report-YYYYMMDD-HHMM.txt. |
$ trame system info $ trame system report
hostname
| get | Print the host name. |
| set <name> | Root. Set the host name: 1 to 63 letters, digits or dashes, not starting or ending with a dash. |
set writes /etc/hostname and adds the name to
the 127.0.0.1 line of /etc/hosts so it
resolves. When a graphical session runs, the running name is left alone
(X clients would stop opening windows): the change applies at the next
restart, and the JSON says "restart":true.
# trame hostname set kitchen
service
The SysV init services: executable scripts of /etc/init.d,
boot scripts left out.
| list | Services, running or stopped, enabled at boot or not. |
| status <name> | Description, state and boot state of one service. |
| start | stop | restart <name> | Root. Run the init script. Start of a running service or stop of a stopped one changes nothing. |
| enable | disable <name> | Root. Add or remove the
service in RUN_DAEMONS of
/etc/rcS.conf. |
Some services are started by rcS itself, outside
RUN_DAEMONS: the login manager of
LOGIN_MANAGER and dbus, the scripts of
RUN_SCRIPTS (such as network.sh), syslogd and
klogd. They show as enabled, and disable refuses them
(exit code 5): edit /etc/rcS.conf for those.
$ trame service status httpd # trame service enable httpd # trame service start httpd
time
| get | Date, UTC time, epoch and timezone. |
| set <datetime> | Root. Set the clock,
"YYYY-MM-DD HH:MM[:SS]" or
YYYY-MM-DDTHH:MM[:SS], in the configured
timezone. |
| ntp [server] | Root. Sync once by NTP
(ntpd -q), default server
pool.ntp.org. |
| tz [get] | Print the timezone. |
| tz set <name> | Root. A zoneinfo name
(Europe/Paris) or a POSIX string
(CET-1CEST,M3.5.0,M10.5.0/3). |
| tz list [area] | Timezones, all or of one area
(Europe). Needs the tzdata package. |
The timezone goes to /etc/TZ; a zoneinfo name also links
/etc/localtime. After set and
ntp, the hardware clock is saved in UTC, or in local time
when line 3 of /etc/adjtime is LOCAL (dual
boot with Windows).
$ trame time tz list Europe # trame time tz set Europe/Zurich # trame time ntp
network
Live state of the interfaces, and the boot configuration.
| Action | Effect |
|---|---|
| show [iface] | Interfaces with state, MAC and addresses, or the details of one (type, cable plugged in). |
| status | Connected or not, interface, gateway, DNS. |
| check | Diagnose step by step: link, gateway (ping), DNS
(resolve slitaz.org), Internet (reach
http://mirror.slitaz.org/), with a hint on the first
failure. Exit code 2 unless the Internet is reached. |
| up | down <iface> | Root. Bring an interface up or down. |
| dhcp <iface> | Root. Ask a DHCP lease once (udhcpc). |
| address [add] <iface> <CIDR> | Root. Add an
address now, e.g. 192.168.1.10/24. |
| address flush <iface> | Root. Remove all addresses of the interface. |
| config | Show the boot configuration. |
| config dhcp | Root. Configure by DHCP at boot. |
| config static <ip/prefix> <gateway> [dns...] | Root.
Static IPv4 at boot; the prefix may be a netmask
(192.168.1.10/255.255.255.0). Without DNS server, the
gateway is used. |
| config interface <iface> | Root. Use this wired
interface at boot and turn Wi-Fi off (for Wi-Fi, use
trame wifi connect). |
| dns [get] | DNS servers of /etc/resolv.conf. |
| dns set <ip> [ip...] | Root. Write the servers to
/etc/resolv.conf and DNS_SERVER. A DHCP
renewal may replace them. |
| restart | Root. Apply the boot configuration now
(/etc/init.d/network.sh restart). |
config only writes /etc/network.conf: run
trame network restart to apply it.
$ trame network check # trame network config static 192.168.1.10/24 192.168.1.1 9.9.9.9 # trame network restart
wifi
Trame drives the SliTaz network script: the active network lives in the
WIFI_* keys of /etc/network.conf, the saved
networks in /etc/wpa/wpa.conf (root only, it holds the
keys).
| scan [iface] | Networks around, strongest access point per name. As a user, only the results cached by the kernel: run it with sudo for a fresh scan. |
| list | Saved networks, * on the active one.
Root, since wpa.conf is root only. |
| status | Interface, card present, radio blocked, network, signal, IP address. |
| connect <ssid> [key|-] [wpa|wep|none] | Root. Save and connect, then wait up to 20 seconds for the association; fails on a wrong key or out of range. |
| connect <ssid> [password|-] eap identity=<user> [...] | Root. 802.1x network (eduroam, company), see below. |
| disconnect | Root. Turn Wi-Fi off at boot and stop it. |
| forget <ssid> | Root. Remove a saved network. |
Key rules: - reads the key from stdin (with no echo on a
terminal), so it never shows in ps nor in the shell
history. Without a key, a saved network reuses its saved one and an
unknown network is taken as open. A WPA key has 8 to 63 characters.
802.1x settings follow the eap type:
method=PEAP|TTLS|PWD (default PEAP),
phase2=MSCHAPV2|PAP|GTC|MSCHAP (default MSCHAPV2),
anonymous=<id>, ca_cert=<file>
(absolute path). EAP-TLS is not handled (exit code 4).
$ trame wifi scan # trame wifi connect HomeBox - # trame wifi connect eduroam - eap identity=jdoe@uni.example
bluetooth
Needs the trame-bluetooth package:
spk-add trame-bluetooth. Without it, status
and power still work on the kernel side and say what to
install. Bluetooth is on demand: power on starts
bluetoothd (dbus must run), power off stops it.
| status | Adapter, chip, stack, daemon, blocked, powered, visible, pairing key to compare, files being received, and a hint on what to fix first. |
| devices | Known devices: paired, connected. |
| scan [seconds] | Discover devices (1 to 60 s, default 8), then list them. |
| power on|off | Root. Unblock the radio and start the
daemon, or the reverse. When btusb is blacklisted on
the kernel command line, on loads it and
off unloads it again. |
| visible on|off | Root. Show this computer (under its host name) to phones and headsets for 3 minutes, and accept pairings from them. |
| pair <mac> | Root. Pair and trust a scanned device; accept the request on the device. |
| connect | disconnect <mac> | Root. Connect a paired device, or disconnect it. |
| remove <mac> | Root. Forget (unpair) a device. |
| send <mac> <file> | Send a file to a paired phone or computer. Runs as the user. |
| receive on|off | Accept files from paired devices into
~/Bluetooth for 10 minutes. Runs as the user. |
# trame bluetooth power on $ trame bluetooth scan # trame bluetooth pair AA:BB:CC:DD:EE:FF $ trame bluetooth send AA:BB:CC:DD:EE:FF photo.jpg
locale
| get | The system locale (LANG); warns when
it is not compiled. |
| set <locale> | Root. Set LANG (and
LC_ALL when present) in
/etc/locale.conf, compiling the locale with
localedef first when needed. |
| list | Locales that can be set
(/usr/share/i18n/locales). |
| list installed | Compiled locales
(locale -a). |
The new locale applies at the next login. When
WANTED_LANGS of /etc/slitaz/slitaz.conf is not
empty, set adds the language to it; run
spk relang to install the translations. A locale with no
definition needs spk-add glibc-locale.
# trame locale set fr_CH.UTF-8
log
| show [n] | Last n entries of the Trame log (default 50). |
| follow | Follow the Trame log (tail -f), not
with --json. |
| clear | Root. Empty the Trame log. |
| sources | System logs present, and whether they are readable without root. |
| view <source> [n] | Last n lines (default 50) of a system log. |
| Source | File |
|---|---|
| kernel | /var/log/dmesg.log, else
dmesg |
| boot | /var/log/boot.log |
| system | /var/log/messages |
| daemon | /var/log/daemon.log |
| auth | /var/log/auth.log |
| xorg | /var/log/Xorg.0.log |
| cocon-dm, slim | /var/log/cocon-dm.log,
/var/log/slim.log |
| network | /var/log/network.log |
| trame | the Trame log |
The Trame log, /var/log/trame.log, has one tab-separated
line per change: date (UTC), user, trame, command and
action, parameters, exit code, duration in ms. Previews
(--dry-run, --explain) and actions that change
nothing are not logged.
$ trame log show 10 $ trame log view xorg 100
user
| list [all] | Users from UID 1000; all adds
the system accounts. |
| info <name> | UID, home, shell, groups, locked (as root), autologin. |
| add <name> [shell] | Root. Create a desktop user,
primary group users, member of audio, cdrom, floppy,
video, tty and plugdev when they exist. Default shell
/bin/sh. No password yet. |
| remove <name> [purge] | Root. Delete the user;
purge also deletes the home directory. Refused for
root and for a user who is logged in or runs programs. |
| passwd <name> [-] | Root. Interactive
passwd, or with - the password read from
stdin (asked twice on a terminal). The password is never an
argument. |
| lock | unlock <name> | Root. Lock or unlock password login. Root cannot be locked; unlock needs a password set. |
| groups | Groups and their members. |
| group add|remove <user> <group> | Root. Add a user to a group or remove it. |
| autologin [get] | The user logged in automatically, or
off. |
| autologin set <name>|off | Root. Automatic login at
next boot (never root). autologin off works too. |
The autologin is written for the login manager of
LOGIN_MANAGER in /etc/rcS.conf: cocon-dm
(autologin-user= in /etc/cocon/dm.conf), else
SLiM (auto_login and default_user in
/etc/slim.conf).
# trame user add alice $ echo 's3cret' | sudo trame user passwd alice - # trame user autologin set alice
storage
| list | Disks and partitions: type, filesystem, size, removable, mount point. |
| info <device> | Filesystem, UUID, label, mount point, size. |
| usage | Size, used and free space per filesystem. |
| mount <dev> [mountpoint] [owner=<user>] | Root.
Mount a device, by default on /media/<label>
(or the device name). owner= gives the files of a
FAT, exFAT or NTFS device to that user. |
| umount <dev|mountpoint> | Root. Unmount; the empty
directory under /media is removed. |
| eject <disk> | Root. Unmount every partition of a
removable disk, sync and power it off so it can be unplugged.
Refused (exit code 5) when it holds /,
/home, /boot, /usr or
/var. |
$ trame storage list # trame storage mount /dev/sdb1 owner=alice # trame storage eject /dev/sdb
kernel
| modules list | Loaded modules. |
| modules info <name> | File, version, description, author, licence. |
| modules load | unload <name> | Root. Load or unload a module. A module built into the kernel counts as loaded. |
| modules reload <name> | Root. Unload and load again, e.g. after installing a missing firmware. A module in use gives exit code 5, a built-in one an error: reboot then. |
| detect [list] | Hardware aliases found in
/sys and their modules. |
| detect load | Root. Load the modules of all detected hardware (coldplug). |
| params get [key] | One sysctl value, or all. |
| params set <key>=<value> | Root. Set a sysctl
value now (sysctl -w); not kept after reboot. |
# trame kernel modules reload iwlwifi # trame kernel params set net.ipv4.ip_forward=1
boot
The GRUB menu of an installed system: a GRUB2 grub.cfg or
a GRUB legacy menu.lst.
| info | Where the menu is, its format, who owns it, the firmware (BIOS or UEFI) and the EFI partition booted. |
| entries | Menu entries with their index,
* on the default. |
| default get | set <index> | Default entry; set needs root. |
| timeout get | set <secs> | Menu timeout in seconds,
-1 waits for ever; set needs root. |
Trame looks on /, /boot and the filesystems
mounted under /mnt and /media, then, as root,
on the EFI partitions (the one the firmware booted first), mounted
read-only for the time of the command and following the stub of another
system to its /boot. When the menu is generated by another
system (grub-mkconfig), Trame reads it but refuses to
change it: edit /etc/default/grub there and run
update-grub. Set GRUB_CFG=<path> to use
a given file.
$ trame boot entries # trame boot default set 1 # trame boot timeout set 5
power
| status | AC adapter, batteries: charge, health, time left, cycles. |
| reboot --yes | Root. Restart the computer. |
| poweroff --yes | Root. Shut down. |
| suspend | Root. Suspend to RAM. |
| hibernate | Root. Hibernate to disk. |
| governor list | get | Available and current cpufreq governors. |
| governor set <name> | Root. Set the governor on every CPU. |
$ trame power status # trame power governor set powersave # trame power reboot --yes
display
Screens through xrandr: run these in the graphical session,
as its user (DISPLAY must be set). Only the backlight needs
root.
| list | Outputs and their modes. |
| set-resolution <output> <WxH> | Set a mode the output supports. |
| layout | Laptop screen, external screen and how they are used. |
| layout mirror|external|internal | Same picture on both, external screen only, laptop screen only. |
| layout extend [right|left|above|below] | One desktop over both screens, external on the given side (default right). |
| restore | Apply the saved layout and modes, meant for the login. |
| brightness get | set <0-100> | Backlight in percent; set needs root. |
Layouts and modes are saved per user in
~/.config/trame/display.conf (or under
$XDG_CONFIG_HOME) for restore.
$ trame display layout extend left # trame display brightness set 60
audio
ALSA through amixer. Trame picks the first card and control
with a volume (Master, PCM, Speaker, Headphone), the default card first.
| get | Control, volume in percent, muted. |
| set <0-100> | Root. Set the volume. |
| mute [on|off|toggle] | Root. Mute, unmute or toggle (default). |
| devices | Sound cards (/proc/asound/cards). |
$ trame audio get # trame audio set 70
firewall
The INPUT chain of iptables (spk-add iptables).
Rules are appended to the chain of the running kernel; Trame writes no
rules file.
| list | Rules of the chain (JSON: port rules only). |
| allow <port>[/tcp|/udp] | Root. Accept a port (tcp by default). |
| deny <port>[/tcp|/udp] | Root. Drop a port. |
| flush --yes | Root. Remove every rule of the chain. |
# trame firewall allow 22 # trame firewall deny 53/udp
keyboard
| get | Console keymap of /etc/keymap.conf. |
| set <name> | Root. Write the keymap and load it
(busybox loadkmap from /usr/share/kmap,
else kbd loadkeys). |
| load | Root. Load the configured keymap without writing it (used at boot). |
| list | Available console keymaps. |
| xkb [get] | X layout, variant and options. |
| xkb set <layout> [variant] | Root. Write
/etc/X11/xorg.conf.d/40-Keyboard.conf; applied at once
with setxkbmap when an X display is reachable, else at
the next X start. |
| xkb list [layout] | X layouts, or the variants of one.
Needs xkeyboard-config. |
Some variants are listed as layouts of their own: ch:fr
(Swiss French) stands for ch fr.
# trame keyboard set fr_CH-latin1 # trame keyboard xkb set ch fr
hardware
Read-only. Names come from pci.ids and usb.ids
when they are installed.
| summary | The computer in plain words: model, firmware, CPU, memory, graphics, network, sound, camera, screens, disks, free space, battery, and a health verdict (temperature, disk, battery). |
| pci | usb | Devices with the driver in use. |
| sensors | Temperatures in Celsius. |
| firmware | Network and Bluetooth devices missing a driver
or firmware, and the package that brings it. Trame does not install
it: it prints the command. Needs the mirror file list
(spk-up --list). |
| firmware installed | Firmware packages installed and the drivers that use them. |
$ trame hardware summary $ trame hardware firmware
printer
With CUPS installed, Trame drives it (cupsd must run:
trame service start cupsd). Without CUPS, it sends PDF or
PostScript straight to a network printer on port 9100 (raw backend);
those printers are kept in /etc/slitaz/printers.conf, the
first line being the default.
| status | Backend, service, default printer, number of printers and jobs. |
| list | Printers, state, address, * on the
default. |
| discover | Root, CUPS only. Printers found on the network and USB. |
| add <name> <uri> [driver] | Root. Add a printer
(socket://host:9100, ipp://...). The
first one becomes the default. With CUPS the driver is chosen when
not given; without CUPS the printer must answer and take PDF or
PostScript. |
| remove <name> | Root. Remove a printer. |
| default <name> | Root. Set the default printer. |
| test [name] | Print a test page. |
| print <file> [name] | Print a file (without CUPS, PDF or PostScript only). |
| jobs | Jobs waiting (CUPS). |
| cancel <job> | Cancel a job (CUPS); another user's job needs root. |
# trame printer add Office socket://192.168.1.20:9100 $ trame printer test $ trame printer print report.pdf Office
Configuration and environment
/etc/slitaz/trame.conf is a shell file read at every run:
LOG_PATH="/var/log/trame.log" Log of the changes LOG_LEVEL="info" info | debug | quiet DEFAULT_JSON="no" yes: JSON by default when stdout is not a terminal
LOG_PATH, LOG_LEVEL and
DEFAULT_JSON set in the environment win over the file;
TRAME_CONF names another configuration file. A few
defaults of the sub-commands can also be set in the environment or in
trame.conf, for example GRUB_CFG (boot menu
file), NTP_SERVER (default pool.ntp.org),
WIFI_CONNECT_WAIT (seconds wifi connect waits,
0 to not check) or USER_GROUPS (groups of new users).
JSON output and exit codes
With --json, the result is one line of compact JSON on
stdout: keys in snake_case, real booleans, English values. A change
answers with "changed":true or "changed":false
(nothing to do), and "dry_run":true under
--dry-run. --explain prints
{"explain":[...commands...],"command":"trame <cmd>"}.
The schema of each command is in
/usr/share/trame/schemas/<command>.json, or
trame <command> --schema.
Errors go to stderr, as text, or with --json as an object
whose error stays in English and message is
translated:
{"error":"no such service: foo","message":"...","code":1,"command":"trame service"}
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | User error: bad argument, unknown resource |
| 2 | System error: the underlying command failed |
| 3 | Permission denied: root required |
| 4 | Not implemented |
| 5 | Conflict: state refuses the change, or a pre-hook vetoed it |
$ trame service list --json | jq '.[] | select(.running) | .name' $ trame network check --quiet || echo offline
Hooks
An administrator or a package can react to changes with an executable
script /etc/slitaz/trame.d/hooks/pre-<command> or
post-<command> (e.g. post-user). It
receives TRAME_SUB, TRAME_ACTION,
TRAME_PARAMS (and TRAME_RC for post) in the
environment and the parameters as arguments. A pre-hook that exits
non-zero cancels the change (exit code 5); a failing post-hook only
prints a warning. Hooks never run on read-only actions,
--dry-run, --explain or when nothing changes.
#!/bin/sh # /etc/slitaz/trame.d/hooks/post-keyboard [ "$TRAME_ACTION" = "set" ] && [ "$TRAME_RC" = "0" ] || exit 0 logger "console keymap now $1"
About
Trame is free software under a BSD license (see COPYING).
Sources: hg.slitaz.org/trame.