Shared Server
The shared server is one Rex server that runs as the rex system account,
as rex.service. Members of the rex group can connect to it, and every
program they start runs as rex. It’s the simplest server mode for a few people who are comfortable
sharing one account.
Access to the shared server is access to the rex account. Anyone in
the group can see and type into every session on it and start programs as rex. Only add people you would trust with that account. If people need
their own files and permissions, use the login server instead.
Starting the Server
The package creates the rex account with nologin as its shell, and Rex
starts each terminal with its account’s shell. Give the account a real
shell first, or every terminal on the shared server exits as soon as it
starts:
sudo usermod --shell /bin/bash rexAlpine has neither usermod nor bash by default. Install usermod with
the shadow package and use /bin/sh:
apk add shadow
usermod --shell /bin/sh rexThe account stays locked, with no password, so nobody can log in as rex this way.
Then start the service now and at every boot:
sudo systemctl enable --now rex.serviceOn Alpine, run rc-update add rex, then rc-service rex start.
The server listens on /run/rex/server.sock and keeps its data in /var/lib/rex, the rex account’s home directory.
Giving People Access
Add each person to the rex group. The change applies the next time they
log in:
sudo usermod --append --groups rex aliceOn Alpine, run addgroup alice rex.
Their rex commands look for their own personal
server by default, and start one if
it isn’t running. To use the shared server instead, pass its socket with -S, or set REX_SERVER in their shell profile so every rex command
uses it:
rex -S /run/rex/server.sock ls
export REX_SERVER=/run/rex/server.sockInside the shared server’s own terminals, rex commands already use the
shared server.
The service isn’t sandboxed on purpose. Sandboxing would also restrict the
programs people run in it, so the rex account is the security boundary.
To reach the shared server from another computer, see Remote Access.
Configuration
The shared server reads its configuration file from
the rex account’s home:
/var/lib/rex/.config/rex/init.luaOnly root can edit it, because /var/lib/rex is private to the rex account. After you change it, any member of the group can reload it:
sudo $EDITOR /var/lib/rex/.config/rex/init.lua
rex -S /run/rex/server.sock config reloadTo keep the file somewhere else, pass --config PATH in a drop-in, as
below.
Customizing the Service
Package upgrades replace rex.service, so put changes in a drop-in file
instead. This command creates one and opens it in your editor:
sudo systemctl edit rex.serviceTo change the server’s options, clear ExecStart and set it again. This
example raises the session limit:
[Service]
ExecStart=
ExecStart=/usr/bin/rex server run --listen /run/rex/server.sock \
--state-dir /var/lib/rex --socket-mode 0660 --log-format text \
--max-sessions 128On Alpine, upgrades replace /etc/init.d/rex, so set command_args in /etc/conf.d/rex instead. The package never creates or changes that file.
The same example there leaves out /usr/bin/rex:
command_args="server run --listen /run/rex/server.sock \
--state-dir /var/lib/rex --socket-mode 0660 --log-format text \
--max-sessions 128"Keep the four options from the original command line. The same pattern adds
a network listener for Remote Access or a block
plugin directory with --block-dir. Run rex server run --help for every
option.
Logs
The shared server logs to the journal:
journalctl -u rex.service -fAlpine has no journal, so there the server logs to a file:
tail -f /var/log/rex/server.logThe logs are plain text. For JSON, change --log-format text to --log-format json in a drop-in.
Upgrading
Upgrading the package restarts a running shared server, so it runs the new version right away.
Restarting ends every session and every program in them. Upgrade when
nobody has work running, or hold the package until then, with sudo apt-mark hold rex or sudo zypper addlock rex, or dnf’s versionlock plugin.
The login server doesn’t have this problem. Its sessions survive upgrades.
