Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/scripts/smoke-test-deb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ check_config_init
info "Checking systemd unit file…"
check_unit_file "fail"

info "Checking service file has exactly one ExecStart directive…"
check_single_execstart

# ── Service startup (best-effort) ─────────────────────────────────────────────

check_service_startup
Expand Down
21 changes: 21 additions & 0 deletions .github/scripts/smoke-test-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,27 @@ check_unit_file() {
fi
}

check_single_execstart() {
local unit_file="" count
for path in "${UNIT_FILE_PATHS[@]}"; do
if [ -f "$path" ]; then
unit_file="$path"
break
fi
done
if [ -z "$unit_file" ]; then
warn "Skipping ExecStart check: no unit file found (check_unit_file already reported this)."
return
fi
# Match only non-empty ExecStart= lines; bare 'ExecStart=' is a reset directive.
count=$(grep -c '^ExecStart=[^[:space:]]' "$unit_file" 2>/dev/null || true)
if [ "$count" -eq 1 ]; then
pass "Service file has exactly one ExecStart directive"
else
fail "Service file has $count ExecStart directives (expected exactly 1)"
fi
}

check_service_startup() {
info "[Best-effort] Checking service startup…"
warn "systemd service startup testing is best-effort in containers."
Expand Down
45 changes: 12 additions & 33 deletions .github/scripts/smoke-test-rpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# - Package installs correctly via dnf
# - Expected files and directories are present
# - Binary is functional (--help, --config-init-only)
# - Service registration creates the expected systemd unit file
# - systemd unit file is installed (part of the .rpm package)
# - Default configuration file is generated
#
# Environment variables (required):
Expand All @@ -19,18 +19,8 @@
# script (after-install) gates ALL service-related actions on the
# presence of /run/systemd/system. This means:
# - Config initialization is skipped.
# - Service registration is skipped (no unit file is created).
# - Service enable/start is skipped.
# This script compensates by running --config-init-only and
# service register manually.
#
# DIFFERENCE FROM DEB:
# The .deb package includes the systemd unit file directly (installed
# by dpkg via dh_installsystemd). The .rpm package does NOT bundle the
# unit file; instead, the postinst calls `devolutions-gateway service
# register` to create it at install time. This means that in a container
# without systemd, the unit file will only exist if we manually run
# `service register`.
# This script compensates by running --config-init-only manually.
# ──────────────────────────────────────────────────────────────────────────────

set -euo pipefail
Expand All @@ -50,10 +40,8 @@ WEBAPP_DIR=/usr/share/devolutions-gateway/webapp
CONFIG_DIR=/etc/devolutions-gateway
CONFIG_FILE=$CONFIG_DIR/gateway.json

# The .rpm package does NOT bundle the unit file; it is created by
# `devolutions-gateway service register` at install time (or manually below).
# The .rpm package bundles the unit file directly (installed by fpm/rpm).
UNIT_FILE_PATHS=(
/etc/systemd/system/devolutions-gateway.service
/usr/lib/systemd/system/devolutions-gateway.service
/lib/systemd/system/devolutions-gateway.service
)
Expand Down Expand Up @@ -171,27 +159,18 @@ check_binary_help
info "Checking config initialization…"
check_config_init

# ── Service registration ──────────────────────────────────────────────────────
# The RPM does NOT bundle the systemd unit file. The postinst calls
# `devolutions-gateway service register` to create it. In containers
# without systemd, the postinst skips this, so we try it manually.

info "Checking service registration…"
info "Running service registration manually…"
SERVICE_REG_OUTPUT=$("$BINARY" service register 2>&1) && SERVICE_REG_RC=$? || SERVICE_REG_RC=$?
if [ "$SERVICE_REG_RC" -eq 0 ]; then
pass "Service registration command succeeded"
else
warn "Service registration returned exit code $SERVICE_REG_RC (may require systemd)."
info "Output: $SERVICE_REG_OUTPUT"
fi

# ── systemd unit file ─────────────────────────────────────────────────────────
# Unit file is only present if service register succeeded above;
# absence is a warning rather than a hard failure.
# The .rpm package bundles the unit file directly, so it must be present
# after installation regardless of whether systemd is running.

info "Checking systemd unit file…"
check_unit_file "warn"
check_unit_file "fail"

# ── Single ExecStart directive ────────────────────────────────────────────────
# Regression guard: two ExecStart= lines make systemd refuse to start the service.

info "Checking service file has exactly one ExecStart directive…"
check_single_execstart

# ── Service startup (best-effort) ─────────────────────────────────────────────

Expand Down
2 changes: 2 additions & 0 deletions ci/package-gateway-rpm.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,14 @@ function New-GatewayRpm() {
'--url', 'https://devolutions.net'
'--license', 'Apache-2.0 OR MIT'
'--rpm-attr', '755,root,root:/usr/bin/devolutions-gateway'
'--rpm-attr', '644,root,root:/usr/lib/systemd/system/devolutions-gateway.service'
'--rpm-changelog', $pkgChangelog
'--after-install', 'package/Linux/gateway/rpm/postinst'
'--before-remove', 'package/Linux/gateway/rpm/prerm'
'--after-remove', 'package/Linux/gateway/rpm/postrm'
'--'
"$Bin=/usr/bin/devolutions-gateway"
'package/Linux/gateway/rpm/service=/usr/lib/systemd/system/devolutions-gateway.service'
"$generatedUpstreamChangelog=/usr/share/doc/devolutions-gateway/ChangeLog"
"$pkgDir/copyright=/usr/share/doc/devolutions-gateway/copyright"
"$LibxmfFile=/usr/lib/devolutions-gateway/libxmf.so"
Expand Down
14 changes: 9 additions & 5 deletions ci/tlk.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ class TlkRecipe
$s = New-Changelog -Format 'RpmPackaging' -InputFile $UpstreamChangelogFile -Packager $Packager -Email $Email
Set-Content -Path $RpmPackagingChangelogFile -Value $s

$FpmArgs = @(
$FpmOptions = @(
'--force'
'--verbose'
'-s', 'dir'
Expand All @@ -882,24 +882,28 @@ class TlkRecipe
'--license', 'Apache-2.0 OR MIT'
'--rpm-attr', "755,root,root:/usr/bin/$PkgName"
'--rpm-changelog', $RpmPackagingChangelogFile
'--after-install', "$InputPackagePath/$($this.Product)/rpm/postinst"
'--after-install', "$InputPackagePath/$($this.Product)/rpm/postinst"
'--before-remove', "$InputPackagePath/$($this.Product)/rpm/prerm"
'--after-remove', "$InputPackagePath/$($this.Product)/rpm/postrm"
'--'
)

$FpmFiles = @(
"$Executable=/usr/bin/$PkgName"
"$RpmUpstreamChangelogFile=/usr/share/doc/$PkgName/ChangeLog"
"$CopyrightFile=/usr/share/doc/$PkgName/copyright"
)

if ($this.Product -eq "gateway") {
$FpmArgs += @(
$FpmOptions += '--rpm-attr', '644,root,root:/usr/lib/systemd/system/devolutions-gateway.service'
$FpmFiles += @(
"$InputPackagePath/gateway/rpm/service=/usr/lib/systemd/system/devolutions-gateway.service",
"$DGatewayWebClient=/usr/share/devolutions-gateway/webapp/client",
"$DGatewayWebPlayer=/usr/share/devolutions-gateway/webapp/player",
"$DGatewayLibXmf=/usr/lib/devolutions-gateway/libxmf.so"
)
}

& 'fpm' @FpmArgs | Out-Host
& 'fpm' @FpmOptions '--' @FpmFiles | Out-Host

if (Test-Path Env:TARGET_OUTPUT_PATH) {
$TargetOutputPath = $Env:TARGET_OUTPUT_PATH
Expand Down
1 change: 1 addition & 0 deletions devolutions-gateway/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ fn run() -> anyhow::Result<()> {
After=network-online.target

[Service]
ExecStart=
ExecStart=/usr/bin/devolutions-gateway --service
Restart=on-failure

Expand Down
3 changes: 2 additions & 1 deletion package/Linux/gateway/debian/service
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[Unit]
Description=Devolutions Gateway
After=network-online.target

[Service]
ExecStart=/usr/bin/devolutions-gateway --service
Restart=on-failure

[Install]
WantedBy=multi-user.target
WantedBy=multi-user.target
5 changes: 2 additions & 3 deletions package/Linux/gateway/rpm/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ if [ ! -d /etc/devolutions-gateway ]; then
fi

if [ -d /run/systemd/system ]; then
/usr/bin/devolutions-gateway service register >/dev/null
systemctl daemon-reload
/usr/bin/devolutions-gateway --config-init-only >/dev/null
systemctl enable --now devolutions-gateway >/dev/null 2>&1
systemctl restart devolutions-gateway >/dev/null 2>&1
systemctl enable --now devolutions-gateway >/dev/null 2>&1 || true
systemctl restart devolutions-gateway >/dev/null 2>&1 || true
fi
8 changes: 6 additions & 2 deletions package/Linux/gateway/rpm/postrm
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ set -e

action="$1"

# Only do complete clean-up on purge.
if [ "$action" != "purge" ] ; then
if [ -d /run/systemd/system ]; then
systemctl daemon-reload >/dev/null 2>&1 || true
fi

# Only do complete clean-up on final erase ($1 == 0); upgrades pass $1 >= 1.
if [ "$action" -ne 0 ] ; then
exit 0
fi

Expand Down
7 changes: 3 additions & 4 deletions package/Linux/gateway/rpm/prerm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ if [ "$action" = "upgrade" ] ; then
fi

if [ -d /run/systemd/system ]; then
systemctl stop devolutions-gateway >/dev/null 2>&1
/usr/bin/devolutions-gateway service unregister >/dev/null
systemctl daemon-reload
fi
systemctl stop devolutions-gateway >/dev/null 2>&1 || true
systemctl disable devolutions-gateway >/dev/null 2>&1 || true
fi
10 changes: 10 additions & 0 deletions package/Linux/gateway/rpm/service
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=Devolutions Gateway
After=network-online.target

[Service]
ExecStart=/usr/bin/devolutions-gateway --service
Restart=on-failure

[Install]
WantedBy=multi-user.target
Loading