Upgrading

You can upgrade Rex using your standard package manager that you installed with. If you used the install.sh script, running that again is also safe; it merely detects and invokes your package manager.

On Linux, install.sh and standard package managers auto-restart the running server. On FreeBSD and Windows, nothing restarts automatically; you must manually restart the server into the latest version. See FreeBSD and Windows.

Upgrading ends every session on a running shared server. The login server and personal servers keep their sessions. See What Restarts.

Upgrading the Package

Installed withUpgrade
Debian, Ubuntusudo apt-get update && sudo apt-get install --only-upgrade rex
Fedora, RHELsudo dnf upgrade --refresh rex
openSUSEsudo zypper update rex
Arch Linuxsudo pacman -Syu
Omarchyomarchy update
Alpineapk update && apk add -u rex
FreeBSDpkg upgrade -r rex rex
Nix profilenix profile upgrade --regex '.*superlogical.*'
Install scriptRun the same command you installed with.
--tarballRun the install script again with --tarball.
Amazon Linux 2Run the install script again.
WindowsSee Windows.

When you run the install script again, pass the same --channel you installed with. Without it, the script switches the repository to the default channel.

What Restarts

The package restarts the Rex services that are running, and leaves stopped ones stopped. In containers without a running init system, it restarts nothing, and neither does the FreeBSD package. See FreeBSD.

The package never restarts rex.socket or rex-login-server.socket. A server that a socket started restarts like any other, and one that hasn’t started yet runs the new version when the first client connects. If a new version changes a socket unit, the change applies once you stop the socket and its service and start the socket again, or at the next reboot.

ServerOn upgradeSessionsRuns the new version
Shared serverRestartsEndRight away
Login serverRestartsSurviveRight away
Account serversKeep runningSurviveWhen their sessions end
Personal serverKeeps runningSurviveWhen it stops

Restarting the shared server ends every session and every program in them. Upgrade when nobody has work running, or hold the package until then.

The servers the login server starts for each account keep running the version they started with. Each one stops around 10 seconds after its last session ends and its last client disconnects, and the next connection starts it again on the new version. On machines with systemd-logind, a person can switch sooner by running rex server stop on the machine as themselves, which ends their sessions.

A personal server that a rex command started stops on its own once it’s idle, so it picks up the new version by itself. One started with rex server start keeps running the old version until you stop it and start it again:

rex server stop
rex server start

Checking the Version

rex version shows the version that’s installed, and rex server status shows the version of the server that’s running:

rex version
rex server status

If the first line of rex version doesn’t match the version: line of rex server status, that server is still running the old version. Through the login server, rex server status shows the version of your account’s server.

Holding an Upgrade

To keep Rex at its current version until you’re ready:

Package managerHoldRelease
aptsudo apt-mark hold rexsudo apt-mark unhold rex
dnfsudo dnf versionlock add rexsudo dnf versionlock delete rex
zyppersudo zypper addlock rexsudo zypper removelock rex
pacmanAdd IgnorePkg = rex under [options] in /etc/pacman.confRemove that line
apkapk add rex=VERSIONapk add -u rex
pkgpkg lock rexpkg unlock rex

On RHEL and its rebuilds, versionlock is a plugin. Install it with sudo dnf install 'dnf-command(versionlock)'. Fedora has it built in.

On Alpine, VERSION is the full version, such as 0.1.0-r0. apk info -e -v rex shows the one that’s installed.

Keeping Your Changes

Upgrades keep your changes to:

  • The accounts file, /etc/rex/accounts.jsonc
  • The PAM policy, /etc/pam.d/rex-login-server
  • Drop-ins for rex.service, rex-login-server.service, and their sockets
  • /etc/conf.d/rex and /etc/conf.d/rex-login-server on Alpine
  • /etc/rc.conf on FreeBSD

Upgrades replace the services themselves, rex.service, rex-login-server.service, rex.socket, rex-login-server.socket, the scripts in /etc/init.d, and the scripts in /usr/local/etc/rc.d on FreeBSD. On FreeBSD, they replace the PAM policy too. See FreeBSD. Put your changes in a drop-in or /etc/conf.d instead, as Customizing the Service shows.

If you changed a config file and a new version of Rex changes it too, you keep yours, and the new one is saved beside it:

Package managerNew file saved asNotes
apt.dpkg-distapt asks first. The install script doesn’t ask.
dnf, zypper.rpmnew
apk.apk-new
pkg.sampleOnly the accounts file. pkg updates the sample on every upgrade.

Compare the two and copy over any changes you want. The SSH fallback, /etc/ssh/ssh_config.d/50-rex.conf, is the exception on dnf and zypper: an upgrade replaces it and saves yours as .rpmsave.

Client and Server Versions

Rex for Mac and the server don’t need to be the same version, and either one can be newer. A newer client can’t use features an older server doesn’t have. When it needs one, it says so:

this server is too old for rex client ls; it needs Rex 0.1.0 or later

If the two are too far apart to work together at all, the server refuses the connection, and the message ends with update the server or update the client.

Switching Channels and Downgrading

Switching channels from snapshot to preview or stable upgrades Rex as usual. Switching back to snapshot is a downgrade, because snapshot versions sort below every release. A downgrade doesn’t happen on its own, so ask for the version you want:

Package managerList versionsDowngrade
aptapt-cache madison rexsudo apt-get install --allow-downgrades rex=VERSION
dnfdnf list --showduplicates rexsudo dnf downgrade rex-VERSION
zypperzypper search -s -x rexsudo zypper install --oldpackage rex-VERSION
pacmanOne version only. See Arch Linux.sudo pacman -U URL
apkapk search -a -x rexapk add rex=VERSION
pkgpkg search -r rex rexSee FreeBSD.

A downgrade restarts services the same way an upgrade does. Your data is safe across a downgrade. A version of Rex that finds data written in a newer format refuses to use it instead of overwriting it.

Changing How Rex Is Installed

Keep one copy of Rex on a machine. The --tarball binary in /usr/local/bin comes before the package’s /usr/bin/rex on the usual PATH, so with both installed, rex commands and the personal servers they start run the tarball’s version, whichever one you upgrade. To see every rex on your PATH:

which -a rex

To move from --tarball to a package, install the package, then remove the binary:

sudo rm /usr/local/bin/rex

To move from a package to --tarball or Nix, remove the package first:

Package managerRemove
aptsudo apt-get remove rex
dnfsudo dnf remove rex
zyppersudo zypper remove rex
pacmansudo pacman -R rex
apkapk del rex
pkgpkg delete rex

Removing the package stops and disables its services and sockets, which ends every session on the shared server. rex-bin from the AUR doesn’t, so stop and disable them yourself first. See Arch Linux.

Removing the package keeps /var/lib/rex and the rex account, so installing the package again picks up the shared server’s data. On FreeBSD, it keeps /var/db/rex, and your settings in /etc/rc.conf.

The install script and the commands on the other install tabs set up the same repository, so you can switch between them. On Alpine, the script puts the repository in /etc/apk/repositories.d/rex.list, and the Alpine tab adds it to /etc/apk/repositories. Keep only one of them.

NixOS

Update the Rex input in your flake, then switch:

nix flake update rex
sudo nixos-rebuild switch --flake .

nixos-rebuild switch restarts the Rex service when Rex changes, the same as a package upgrade: the shared server’s sessions end, and account servers keep the old version until their sessions end.

flake.lock holds Rex at its current version until you update it, so there’s nothing else to do to hold an upgrade.

FreeBSD

pkg can’t restart services, so after an upgrade, the services that were running keep the old version. pkg says which ones at the end of its output, and so does the install script. Restart each one when you’re ready:

service rex restart
service rex-login-server restart

Restarting rex ends every session on the shared server, the same as on Linux. Restarting rex-login-server keeps each account’s server and its sessions, and they keep the old version until their sessions end.

Upgrades keep your changes to the accounts file, but replace the PAM policy in /usr/local/etc/pam.d. To change the policy, edit a copy in /etc/pam.d instead, as Login Server shows.

pkg doesn’t downgrade with pkg install, so delete the newer version first. Deleting stops both services, which ends every session on the shared server:

pkg delete rex
pkg install -r rex rex-VERSION

VERSION is the full version, such as 0.0.1792508098.g07b896. pkg info rex shows the one that’s installed.

Windows

Upgrade Rex the same way you installed it:

Installed withUpgrade
WinGetwinget upgrade --id Superlogical.RexServer.Preview --source rex
Manual MSIDownload the new MSI and run it.
Manual ZipStop the server, then extract the new zip over the old folder.

Stop the server before you upgrade with WinGet. WinGet can’t replace the files of a running server, so the upgrade fails with “Access is denied” and Rex stays at the old version.

In all cases, nothing automatically restarts. How you restart your server depends on how it was started, as Server Lifetimes explains:

Started byTo run the new version
Any rex commandNothing. It stops once it’s idle, and the next command starts the new version.
rex server startrex server stop, then rex server start
rex server install --userrex server stop, then rex server install --user, or sign in again
rex server installrex server stop, then sc.exe start RexServer-<SID>

sc.exe start needs a terminal opened with Run as administrator. See Stopping and Restarting.

Warning! Restarting the server ends every program running in its sessions. The server saves its session layouts but the programs that were running in them don’t come back today.

Holding an Upgrade

To keep WinGet from upgrading Rex until you’re ready, pin it:

winget pin add --id Superlogical.RexServer.Preview --source rex

To see your pins, and to remove this one:

winget pin list --source rex
winget pin remove --id Superlogical.RexServer.Preview --source rex

winget pin list shows nothing without --source rex, because the source is explicit. An MSI or zip you installed yourself is never upgraded until you install a new one.