fix(gui-client): don't stop service after upgrade on Fedora (#10539)

On Fedora, when a package gets upgraded, the new package is installed
first, followed by the uninstall of the old package. As a result, the
`prerm` script is called after the `postinst` script of the new package.

In our `prerm` script, we stop the tunnel service. On package upgrades,
this results in us stopping the tunnel service after installing the new
package, confronting the user with an error that the tunnel service is
not running.

`rpm` passes arguments to these maintenance scripts. In the case of
`prerm`, we receive the count of how many other instances of this
packages are installed. To fix this bug, we check whether the first
argument to the script is "1", meaning that we are being upgraded and
should not stop the tunnel service.
This commit is contained in:
Thomas Eizinger
2025-10-10 10:53:32 +11:00
committed by GitHub
parent d11bd14fce
commit 5b60d9d64d
6 changed files with 24 additions and 7 deletions

View File

@@ -1,6 +1,4 @@
#!/usr/bin/env bash
# Usage: dpkg will call this after installing our files
# This must be idempotent
set -euo pipefail

View File

@@ -1,6 +1,4 @@
#!/usr/bin/env bash
# Usage: dpkg will call this after installing our files
# This must be idempotent
set -euo pipefail

View File

@@ -1,5 +1,4 @@
#!/usr/bin/env bash
# Usage: dpkg will call this after installing our files
set -euo pipefail

View File

@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -euo pipefail
SERVICE_NAME="firezone-client-tunnel"
# `rpm` calls `prerm` of the old package _after_ it has installed the new package.
# The first parameter indicates, how many other instances of the package are still installed.
# If we are being upgraded, this will be 1.
# In that case, we do _not_ want to stop the systemd service, otherwise the user will be greeted with "Firezone Tunnel service is not running".
if [ "$1" == 1 ]; then
return
fi
sudo systemctl disable "$SERVICE_NAME"
sudo systemctl stop "$SERVICE_NAME"

View File

@@ -11,7 +11,7 @@
"deb": {
"preInstallScript": "./linux_package/preinst",
"postInstallScript": "./linux_package/postinst",
"preRemoveScript": "./linux_package/prerm",
"preRemoveScript": "./linux_package/prerm_deb",
"files": {
"/usr/lib/systemd/system/firezone-client-tunnel.service": "./linux_package/firezone-client-tunnel.service",
"/usr/lib/sysusers.d/firezone-client-tunnel.conf": "./linux_package/sysusers.conf",
@@ -21,7 +21,7 @@
},
"rpm": {
"postInstallScript": "./linux_package/postinst",
"preRemoveScript": "./linux_package/prerm",
"preRemoveScript": "./linux_package/prerm_rpm",
"files": {
"/usr/lib/systemd/system/firezone-client-tunnel.service": "./linux_package/firezone-client-tunnel.service",
"/usr/lib/sysusers.d/firezone-client-tunnel.conf": "./linux_package/sysusers.conf",