Skip to content

Commit a5d75a3

Browse files
committed
.
1 parent ae8b243 commit a5d75a3

10 files changed

Lines changed: 53 additions & 73 deletions

File tree

.github/scripts/smoke-test-deb.sh

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@
1515
# PACKAGE_NAME Package name (e.g. devolutions-gateway).
1616
#
1717
# LIMITATION — systemd in containers:
18-
# Docker containers do not normally run systemd, so the postinst script
19-
# skips config initialization and service enablement (both gated on
20-
# /run/systemd/system). This script compensates by running
21-
# --config-init-only manually. Full service start/stop validation is
22-
# best-effort and only attempted when systemd is detected.
18+
# Docker containers do not normally run systemd. The postinst gates
19+
# service enable/start on /run/systemd/system. Full service start/stop
20+
# validation is best-effort and only attempted when systemd is detected.
2321
# ──────────────────────────────────────────────────────────────────────────────
2422

2523
set -euo pipefail
@@ -154,8 +152,7 @@ info "Checking binary functionality…"
154152
check_binary_help
155153

156154
# ── Config initialization ─────────────────────────────────────────────────────
157-
# The postinst runs --config-init-only only when systemd is present.
158-
# In a container without systemd we run it manually.
155+
# The postinst always runs --config-init-only regardless of systemd presence.
159156

160157
info "Checking config initialization…"
161158
check_config_init

.github/scripts/smoke-test-lib.sh

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,6 @@ check_binary_help() {
8787
}
8888

8989
check_config_init() {
90-
if [ ! -f "$CONFIG_FILE" ]; then
91-
info "Config file not generated by postinst (expected without systemd)."
92-
info "Running config initialization manually…"
93-
CONFIG_INIT_LOG=$(mktemp)
94-
if "$BINARY" --config-init-only > "$CONFIG_INIT_LOG" 2>&1; then
95-
pass "Config initialization command succeeded"
96-
else
97-
echo "config-init-only output:"
98-
cat "$CONFIG_INIT_LOG"
99-
fail "Config initialization command failed"
100-
fi
101-
rm -f "$CONFIG_INIT_LOG"
102-
fi
103-
10490
if [ -f "$CONFIG_FILE" ]; then
10591
pass "Default config file exists: $CONFIG_FILE"
10692
if python3 -c "import json; json.load(open('$CONFIG_FILE'))" 2>/dev/null; then
@@ -109,7 +95,7 @@ check_config_init() {
10995
fail "$(basename "$CONFIG_FILE") exists but is not valid JSON"
11096
fi
11197
else
112-
fail "Default config file missing after initialization: $CONFIG_FILE"
98+
fail "Default config file missing after installation: $CONFIG_FILE"
11399
fi
114100
}
115101

.github/scripts/smoke-test-rpm.sh

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@
1616
#
1717
# LIMITATION — systemd in containers:
1818
# Docker containers do not normally run systemd. The RPM postinst
19-
# script (after-install) gates ALL service-related actions on the
20-
# presence of /run/systemd/system. This means:
21-
# - Config initialization is skipped.
22-
# - Service enable/start is skipped.
23-
# This script compensates by running --config-init-only manually.
19+
# gates service enable/start on /run/systemd/system. Full service
20+
# start/stop validation is best-effort and only attempted when
21+
# systemd is detected.
2422
# ──────────────────────────────────────────────────────────────────────────────
2523

2624
set -euo pipefail
@@ -153,8 +151,7 @@ info "Checking binary functionality…"
153151
check_binary_help
154152

155153
# ── Config initialization ─────────────────────────────────────────────────────
156-
# RPM postinst runs --config-init-only only when systemd is present.
157-
# In a container without systemd we run it manually.
154+
# The postinst always runs --config-init-only regardless of systemd presence.
158155

159156
info "Checking config initialization…"
160157
check_config_init

ci/package-gateway-rpm.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,15 @@ function New-GatewayRpm() {
7070
'--license', 'Apache-2.0 OR MIT'
7171
'--rpm-attr', '755,root,root:/usr/bin/devolutions-gateway'
7272
'--rpm-attr', '644,root,root:/usr/lib/systemd/system/devolutions-gateway.service'
73+
'--rpm-attr', '644,root,root:/usr/lib/systemd/system-preset/85-devolutions-gateway.preset'
7374
'--rpm-changelog', $pkgChangelog
7475
'--after-install', 'package/Linux/gateway/rpm/postinst'
7576
'--before-remove', 'package/Linux/gateway/rpm/prerm'
7677
'--after-remove', 'package/Linux/gateway/rpm/postrm'
7778
'--'
7879
"$Bin=/usr/bin/devolutions-gateway"
7980
'package/Linux/gateway/rpm/service=/usr/lib/systemd/system/devolutions-gateway.service'
81+
'package/Linux/gateway/rpm/preset=/usr/lib/systemd/system-preset/85-devolutions-gateway.preset'
8082
"$generatedUpstreamChangelog=/usr/share/doc/devolutions-gateway/ChangeLog"
8183
"$pkgDir/copyright=/usr/share/doc/devolutions-gateway/copyright"
8284
"$LibxmfFile=/usr/lib/devolutions-gateway/libxmf.so"

ci/tlk.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,8 +895,10 @@ class TlkRecipe
895895

896896
if ($this.Product -eq "gateway") {
897897
$FpmOptions += '--rpm-attr', '644,root,root:/usr/lib/systemd/system/devolutions-gateway.service'
898+
$FpmOptions += '--rpm-attr', '644,root,root:/usr/lib/systemd/system-preset/85-devolutions-gateway.preset'
898899
$FpmFiles += @(
899900
"$InputPackagePath/gateway/rpm/service=/usr/lib/systemd/system/devolutions-gateway.service",
901+
"$InputPackagePath/gateway/rpm/preset=/usr/lib/systemd/system-preset/85-devolutions-gateway.preset",
900902
"$DGatewayWebClient=/usr/share/devolutions-gateway/webapp/client",
901903
"$DGatewayWebPlayer=/usr/share/devolutions-gateway/webapp/player",
902904
"$DGatewayLibXmf=/usr/lib/devolutions-gateway/libxmf.so"

package/Linux/gateway/debian/postinst

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
#!/bin/sh
22

3+
set -e
4+
35
if [ ! -d /etc/devolutions-gateway ]; then
46
/bin/mkdir /etc/devolutions-gateway
5-
/bin/chmod 655 /etc/devolutions-gateway
7+
/bin/chmod 750 /etc/devolutions-gateway
68
fi
79

8-
if [ -d /run/systemd/system ]; then
9-
# Generate /etc/devolutions-gateway/gateway.json
10-
/usr/bin/devolutions-gateway --config-init-only >/dev/null
11-
fi
10+
/usr/bin/devolutions-gateway --config-init-only >/dev/null
1211

13-
set -e
1412
# Automatically added by dh_installsystemd/13.18ubuntu2.1
1513
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
1614
# The following line should be removed in trixie or trixie+1
@@ -33,11 +31,21 @@ if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-decon
3331
if [ -z "${DPKG_ROOT:-}" ] && [ -d /run/systemd/system ]; then
3432
systemctl --system daemon-reload >/dev/null || true
3533
if [ -n "$2" ]; then
36-
_dh_action=restart
37-
else
38-
_dh_action=start
34+
# Upgrade: restart only if already running.
35+
deb-systemd-invoke try-restart 'devolutions-gateway.service' >/dev/null || true
3936
fi
40-
deb-systemd-invoke $_dh_action 'devolutions-gateway.service' >/dev/null || true
4137
fi
4238
fi
4339
# End automatically added section
40+
41+
if [ "$1" = "configure" ] && [ -z "$2" ]; then
42+
echo ""
43+
echo "Devolutions Gateway has been installed."
44+
echo "Edit /etc/devolutions-gateway/gateway.json, then run:"
45+
if [ -d /run/systemd/system ]; then
46+
echo " systemctl start devolutions-gateway"
47+
else
48+
echo " Start devolutions-gateway using your init system or run it directly."
49+
fi
50+
echo ""
51+
fi

package/Linux/gateway/rpm/postinst

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
#!/bin/sh
22

3+
set -e
4+
35
if [ ! -d /etc/devolutions-gateway ]; then
46
/bin/mkdir /etc/devolutions-gateway
5-
/bin/chmod 655 /etc/devolutions-gateway
7+
/bin/chmod 750 /etc/devolutions-gateway
68
fi
79

8-
if [ -d /run/systemd/system ]; then
9-
systemctl daemon-reload
10-
/usr/bin/devolutions-gateway --config-init-only >/dev/null
11-
systemctl enable --now devolutions-gateway >/dev/null 2>&1 || true
12-
systemctl restart devolutions-gateway >/dev/null 2>&1 || true
10+
/usr/bin/devolutions-gateway --config-init-only >/dev/null
11+
12+
%systemd_post devolutions-gateway.service
13+
14+
if [ "$1" -eq 1 ]; then
15+
echo ""
16+
echo "Devolutions Gateway has been installed."
17+
echo "Edit /etc/devolutions-gateway/gateway.json, then run:"
18+
if [ -d /run/systemd/system ]; then
19+
echo " systemctl start devolutions-gateway"
20+
else
21+
echo " Start devolutions-gateway using your init system or run it directly."
22+
fi
23+
echo ""
1324
fi

package/Linux/gateway/rpm/postrm

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,7 @@
22

33
set -e
44

5-
action="$1"
5+
%systemd_postun_with_restart devolutions-gateway.service
66

7-
if [ -d /run/systemd/system ]; then
8-
systemctl daemon-reload >/dev/null 2>&1 || true
9-
fi
10-
11-
# Only do complete clean-up on final erase ($1 == 0); upgrades pass $1 >= 1.
12-
if [ "$action" -ne 0 ] ; then
13-
exit 0
14-
fi
15-
16-
if [ -d /etc/devolutions-gateway ]; then
17-
rm -rf /etc/devolutions-gateway
18-
fi
7+
# Configuration in /etc/devolutions-gateway is intentionally preserved on removal.
8+
# RPM has no purge concept; admins can remove the directory manually if desired.

package/Linux/gateway/rpm/prerm

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,4 @@
22

33
set -e
44

5-
action="$1"
6-
if [ "$2" = "in-favour" ]; then
7-
# Treat conflict remove as an upgrade.
8-
action="upgrade"
9-
fi
10-
11-
# Don't clean-up just for an upgrade.
12-
if [ "$action" = "upgrade" ] ; then
13-
exit 0
14-
fi
15-
16-
if [ -d /run/systemd/system ]; then
17-
systemctl stop devolutions-gateway >/dev/null 2>&1 || true
18-
systemctl disable devolutions-gateway >/dev/null 2>&1 || true
19-
fi
5+
%systemd_preun devolutions-gateway.service

package/Linux/gateway/rpm/preset

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
enable devolutions-gateway.service

0 commit comments

Comments
 (0)