Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(gui-client/linux): add install script and change group to firezone-client #4879

Merged
merged 4 commits into from
May 2, 2024
Merged
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
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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just in case we need it to be separate from the gateway group


[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
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"
Comment on lines +23 to +24
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we just need to restart the current login session? I.e. logout and back in?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried on 20.04, but it doesn't seem to work. Maybe it's something particular Ubuntu does, I know it used to work on other distros in the past.

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
Loading