Merge pull request #1692 from tgstation/1689-DebUser

Run systemd as the user `tgstation-server`
This commit is contained in:
Jordan Dominion
2023-11-10 08:58:25 -05:00
committed by GitHub
8 changed files with 49 additions and 23 deletions
+1 -1
View File
@@ -34,7 +34,7 @@ You can of course, as always, ask for help at [#coderbus](irc://irc.rizon.net/co
### Development Environment
You need the .NET 8.0 SDK and npm>=v5.7 (in your PATH) to compile the server.
You need the .NET 8.0 SDK, node>=v20, and npm>=v5.7 (in your PATH) to compile the server.
The recommended IDE is Visual Studio 2022 or VSCode.
+3 -1
View File
@@ -117,6 +117,8 @@ sudo dpkg --add-architecture i386 \
&& sudo systemctl start tgstation-server
```
The service will execute as the newly created user: `tgstation-server`.
##### Debian
The `aspnetcore-runtime-8.0` package isn't yet available on mainline Debian and must be [installed from Microsoft](https://learn.microsoft.com/en-us/dotnet/core/install/linux-debian) first. Use the following one-liner to add their packages repository.
@@ -143,7 +145,7 @@ The following dependencies are required.
[Download the latest release .zip](https://github.com/tgstation/tgstation-server/releases/latest). Choose `ServerConsole`.
If you have SystemD installed, we recommend installing the service unit [here](./build/tgstation-server.service). It assumes TGS is installed into `/opt/tgstation-server` and you will be using the but feel free to adjust it to your needs. Note that the server will need to have it's configuration file setup before running with SystemD.
If you have SystemD installed, we recommend installing the service unit [here](./build/tgstation-server.service). It assumes TGS is installed into `/opt/tgstation-server`, it is executing as the user `tgstation-server`, and you will be using the console runner, but feel free to adjust it to your needs. Note that the server will need to have it's configuration file setup before running with SystemD.
Alternatively, to launch the server in the current shell, run `./tgs.sh` in the root of the installation directory. The process will run in a blocking fashion. SIGQUIT will close the server, terminating all live game instances.
+15 -5
View File
@@ -9,16 +9,27 @@ set -x
dpkg --add-architecture i386
apt-get update
# This package set needs cleanup probably, StackOverflow copypasta
apt-get install -y npm \
apt-get install -y \
build-essential \
binutils \
lintian \
debhelper \
dh-make \
devscripts \
ca-certificates \
curl \
gnupg \
xmlstarlet
# dotnet-sdk-8.0 # Disabled while in preview
# https://github.com/nodesource/distributions
mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
export NODE_MAJOR=20
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
apt-get update
apt-get install nodejs -y
CURRENT_COMMIT=$(git rev-parse HEAD)
rm -rf packaging
@@ -56,14 +67,13 @@ set +e
if [[ -z "$PACKAGING_KEYGRIP" ]]; then
dpkg-buildpackage --no-sign
EXIT_CODE=$?
else
dpkg-buildpackage --sign-key=$PACKAGING_KEYGRIP --sign-command="$SIGN_COMMAND"
cat /tmp/tgs_wrap_gpg_output.log
EXIT_CODE=$?
fi
EXIT_CODE=$?
cat /tmp/tgs_wrap_gpg_output.log
cd ..
exit $EXIT_CODE
+1 -1
View File
@@ -5,7 +5,7 @@ Maintainer: Jordan Dominion <Cyberboss@users.noreply.github.com>
Rules-Requires-Root: no
Build-Depends:
debhelper-compat (= 13),
npm,
nodejs,
#dotnet-sdk-8.0, Disabled while in preview
Standards-Version: 4.6.2
Homepage: https://tgstation.github.io/tgstation-server
+6 -1
View File
@@ -1,9 +1,14 @@
#!/bin/sh -e
adduser --system tgstation-server
mkdir -m 754 -p /var/log/tgstation-server
chown -R tgstation-server /etc/tgstation-server
chown -R tgstation-server /opt/tgstation-server
chown -R tgstation-server /var/log/tgstation-server
#DEBHELPER#
if [ "$1" = "configure" ]; then
chmod 600 /etc/tgstation-server
deb-systemd-helper stop 'tgstation-server.service' >/dev/null || true
echo " _ _ _ _ "
+21 -11
View File
@@ -3,23 +3,23 @@
export DH_VERBOSE = 1
%:
dh $@
dh $@
override_dh_auto_clean:
rm -rf artifacts
dotnet clean -c ReleaseNoWindows
rm -rf artifacts
dotnet clean -c ReleaseNoWindows
override_dh_auto_build:
dotnet restore
cd src/Tgstation.Server.Host.Console && dotnet publish -c Release -o ../../artifacts
cd src/Tgstation.Server.Host && dotnet publish -c Release -o ../../artifacts/lib/Default
rm artifacts/lib/Default/appsettings.yml
build/RemoveUnsupportedRuntimes.sh artifacts/lib/Default
build/RemoveUnsupportedRuntimes.sh artifacts
dotnet restore
cd src/Tgstation.Server.Host.Console && dotnet publish -c Release -o ../../artifacts
cd src/Tgstation.Server.Host && dotnet publish -c Release -o ../../artifacts/lib/Default
rm artifacts/lib/Default/appsettings.yml
build/RemoveUnsupportedRuntimes.sh artifacts/lib/Default
build/RemoveUnsupportedRuntimes.sh artifacts
override_dh_auto_install:
cp build/package/deb/MakeInstall ./Makefile
dh_auto_install --
cp build/package/deb/MakeInstall ./Makefile
dh_auto_install --
override_dh_strip:
@@ -27,3 +27,13 @@ override_dh_shlibdeps:
override_dh_installsystemd:
dh_installsystemd -v --restart-after-upgrade
override_dh_fixperms:
dh_fixperms
find debian/tgstation-server/opt/tgstation-server -exec chmod 544 {} +
find debian/tgstation-server/opt/tgstation-server -type d -exec chmod 555 {} +
find debian/tgstation-server/opt/tgstation-server/lib -exec chmod 744 {} +
find debian/tgstation-server/opt/tgstation-server/lib -type d -exec chmod 755 {} +
find debian/tgstation-server/etc/tgstation-server -exec chmod 644 {} +
find debian/tgstation-server/etc/tgstation-server -type d -exec chmod 755 {} +
chmod 640 debian/tgstation-server/etc/tgstation-server/appsettings.Production.yml
+1 -3
View File
@@ -1,5 +1,3 @@
#!/bin/sh
cd /opt/tgstation-server
export General__SetupWizardMode=Only
exec /usr/bin/dotnet /opt/tgstation-server/lib/Default/Tgstation.Server.Host.dll /tmp/tgs_temp_should_not_be_used --appsettings-base-path=/etc/tgstation-server
exec su -s /bin/sh -c "cd /opt/tgstation-server && export General__SetupWizardMode=Only && exec /usr/bin/dotnet /opt/tgstation-server/lib/Default/Tgstation.Server.Host.dll /tmp/tgs_temp_should_not_be_used --appsettings-base-path=/etc/tgstation-server" tgstation-server
+1
View File
@@ -7,6 +7,7 @@ After=postgresql.service
After=mssql-server.service
[Service]
User=tgstation-server
Type=notify-reload
NotifyAccess=all
WorkingDirectory=/opt/tgstation-server