Skip to content

Commit

Permalink
chore(gui-client/linux): add install script and change group to `fire…
Browse files Browse the repository at this point in the history
…zone-client` (#4879)

Closes #4873
  • Loading branch information
ReactorScram committed May 2, 2024
1 parent 9606dde commit 35a802d
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ ExecStart=firezone-client-ipc
Type=notify
# Unfortunately we may need root to control DNS
User=root
Group=firezone
Group=firezone-client

[Install]
WantedBy=default.target
4 changes: 4 additions & 0 deletions rust/gui-client/src-tauri/deb_files/sysusers.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This file is part of the Firezone Client.
# This creates the `firezone-client` group automatically at startup

g firezone-client -
3 changes: 2 additions & 1 deletion rust/gui-client/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"active": true,
"deb": {
"files": {
"/usr/lib/systemd/system/firezone-client-ipc.service": "./firezone-client-ipc.service"
"/usr/lib/systemd/system/firezone-client-ipc.service": "./deb_files/firezone-client-ipc.service",
"/usr/lib/sysusers.d/firezone-client-ipc.conf": "./deb_files/sysusers.conf"
}
},
"targets": ["deb", "msi"],
Expand Down
2 changes: 1 addition & 1 deletion scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ You can achieve this more easily by using `pre-commit`. See

## Scripting tips

- Use `#!/usr/bin/env bash` along with `set -euo pipefail` in general for dev
- Use `#!/usr/bin/env bash` along with `set -euox pipefail` in general for dev
and test scripts.
- In Docker images and other minimal envs, stick to `#!/bin/sh` and simply
`set -eu`.
7 changes: 5 additions & 2 deletions scripts/build/tauri-rename-ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ make_hash "$BINARY_DEST_PATH.dwp"
make_hash "$BINARY_DEST_PATH.deb"

# Test the deb package, since this script is the easiest place to get a release build
sudo dpkg --install "$BINARY_DEST_PATH.deb"
DEB_PATH=$(realpath "$BINARY_DEST_PATH.deb")
sudo apt-get install "$DEB_PATH"
# Update users / groups
sudo systemd-sysusers

# Debug-print the files. The icons and both binaries should be in here
dpkg --listfiles firezone-client-gui
Expand All @@ -37,5 +40,5 @@ stat /usr/share/icons/hicolor/512x512/apps/firezone-client-gui.png
firezone-client-gui --help | grep "Usage: firezone-client-gui"

# Try to start the IPC service
sudo groupadd --force firezone
sudo groupadd --force firezone-client
sudo systemctl start firezone-client-ipc || systemctl status firezone-client-ipc
24 changes: 24 additions & 0 deletions scripts/firezone-client-gui-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
# Usage: ./firezone-client-gui-install.sh ./firezone-client-gui_VERSION_ARCH.deb
#
# The `./` is necessary
#
# This script should be idempotent
set -euox pipefail

# `apt-get` needs either a leading `./` or `/` to recognize a local file path
DEB_PATH=$(realpath "$1")

echo "Installing Firezone..."
sudo apt-get install "$DEB_PATH"

echo "Adding your user to the firezone-client group..."
# Creates the system group `firezone-client`
sudo systemd-sysusers

This comment has been minimized.

Copy link
@thomaseizinger

thomaseizinger May 10, 2024

Member

Ugh, on Arch, this happens automationally if the package contains a sysuser file.

sudo adduser "$USER" firezone-client

echo "Starting and enabling Firezone IPC service..."
sudo systemctl enable --now firezone-client-ipc

# Unfortunately Ubuntu seems to need a reboot here, at least 20.04 does
echo "Reboot to finish adding yourself to the group"
6 changes: 3 additions & 3 deletions scripts/tests/linux-group.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
source "./scripts/tests/lib.sh"

BINARY_NAME=firezone-client-ipc
FZ_GROUP="firezone"
FZ_GROUP="firezone-client"
SERVICE_NAME=firezone-client-ipc
SOCKET=/run/dev.firezone.client/ipc.sock
export RUST_LOG=info
Expand All @@ -15,15 +15,15 @@ export RUST_LOG=info
sudo cp "rust/target/debug/firezone-headless-client" "/usr/bin/$BINARY_NAME"

# Set up the systemd service
sudo cp "rust/gui-client/src-tauri/$SERVICE_NAME.service" /usr/lib/systemd/system/
sudo cp "rust/gui-client/src-tauri/deb_files/$SERVICE_NAME.service" /usr/lib/systemd/system/
sudo cp "scripts/tests/systemd/env" "/etc/default/firezone-client-ipc"

# The firezone group must exist before the daemon starts
sudo groupadd "$FZ_GROUP"
sudo systemctl start "$SERVICE_NAME" || { systemctl status "$SERVICE_NAME"; exit 1; }

# Make sure the socket has the right permissions
if [ "root firezone" != "$(stat -c '%U %G' $SOCKET)" ]
if [ "root $FZ_GROUP" != "$(stat -c '%U %G' $SOCKET)" ]
then
exit 1
fi
Expand Down

0 comments on commit 35a802d

Please sign in to comment.