# RPM package for Fedora, RHEL and similar. Built by 'make rpm', which fills in # @VERSION@ and makes the source tarball. The scriptlets use plain systemctl, # systemd-sysusers and systemd-tmpfiles rather than Fedora's macros, so the # package can be built anywhere rpmbuild runs (the release workflow builds it on # Ubuntu). They do what packaging/deb/ does for Debian; see the comments there. Name: terraria-server-manager Version: @VERSION@ Release: 1 Summary: Run multiple Terraria and tModLoader dedicated servers with systemd # TODO: no license has been chosen for this project yet License: LicenseRef-Unspecified URL: https://gitea.adbraun.lol/adam/terraria-server-manager Packager: Adam Brown Source0: %{name}-%{version}.tar.gz BuildArch: noarch BuildRequires: make Requires: bash Requires: coreutils Requires: util-linux Requires: unzip Requires: systemd Requires: python3 Requires: openssl # Only needed for tModLoader instances (ICU: they stop with 'Aborted' without it) Recommends: curl Recommends: libicu # Lets the terraria group start, stop and restart servers without sudo Recommends: polkit Suggests: bash-completion %description Provides the terraria@.service template and the terractl command for running any number of vanilla Terraria and tModLoader dedicated servers, each as its own systemd service under an unprivileged terraria user. Server software is not included. 'terractl fetch' downloads the official server zips into /var/lib/terraria/dist, and they are unpacked into each instance on demand. Hosts can also be managed from other hosts (terractl --host, copy, move) through the optional terractld daemon. %prep %setup -q %build # Nothing to build: shell and Python scripts %install make install DESTDIR=%{buildroot} PREFIX=/usr SYSCONFDIR=/etc %post systemd-sysusers terractl.conf >/dev/null 2>&1 || : systemd-tmpfiles --create terractl.conf >/dev/null 2>&1 || : if [ -d /run/systemd/system ]; then systemctl daemon-reload >/dev/null 2>&1 || : # On upgrades the daemon (if it's on) runs the new version right away. It # only serves other hosts; the game servers keep running. if [ "$1" -ge 2 ]; then systemctl try-restart terractld.service >/dev/null 2>&1 || : fi fi # Let the terraria group read the servers' journal (LogNamespace=terraria) /usr/bin/terractl journal-access >/dev/null 2>&1 || : %preun # On removal (not upgrade), stop everything while terractl still exists, so each # server is sent "exit" and saves its world, and take back what was enabled: # rpm, unlike dpkg, has no separate purge. if [ "$1" -eq 0 ] && [ -d /run/systemd/system ]; then systemctl disable --now terractld.service >/dev/null 2>&1 || : for f in /etc/systemd/system/*.wants/terraria-backup@*.timer \ /etc/systemd/system/*.wants/terraria@*.service; do [ -L "$f" ] && systemctl disable "${f##*/}" >/dev/null 2>&1 || : done systemctl stop 'terraria-backup@*.timer' 'terraria-backup@*.service' >/dev/null 2>&1 || : units=$(systemctl list-units --plain --no-legend --all 'terraria@*.service' | awk '{print $1}') if [ -n "$units" ]; then echo "Stopping Terraria instances: $units" # Unquoted on purpose: each unit name must be a separate argument # shellcheck disable=SC2086 systemctl stop $units || : fi fi %postun if [ "$1" -eq 0 ]; then # Drop-ins terractl wrote itself (backup schedules, 'doctor --fix'). Ones # you added with 'systemctl edit' are kept. rm -f /etc/systemd/system/terraria-backup@*.timer.d/terractl.conf \ /etc/systemd/system/terraria-backup@*.service.d/terractl.conf \ /etc/systemd/system/*.d/terractl-locations.conf rmdir /etc/systemd/system/terraria-backup@*.d /etc/systemd/system/terraria@.service.d \ /etc/systemd/system/terractld.service.d 2>/dev/null || : cat >&2 </dev/null 2>&1 || : fi %files /usr/bin/terractl /usr/lib/terraria-server-manager/ /usr/lib/systemd/system/terraria@.service /usr/lib/systemd/system/terraria@.socket /usr/lib/systemd/system/terractld.service /usr/lib/systemd/system/terraria-backup@.service /usr/lib/systemd/system/terraria-backup@.timer /usr/lib/sysusers.d/terractl.conf /usr/lib/tmpfiles.d/terractl.conf /usr/share/polkit-1/rules.d/50-terractl.rules /usr/share/bash-completion/completions/terractl /usr/share/terraria-server-manager/ %doc /usr/share/doc/terraria-server-manager/ %config(noreplace) /etc/default/terractl %config(noreplace) /etc/systemd/journald@terraria.conf