diff --git a/CHANGELOG.md b/CHANGELOG.md index 0404b5bd7..e328ba129 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ All notable changes to this project will be documented in this file. - Removed device and user allowlist functionality, updating the global state, initialization flow, tests, and processors accordingly, and cleaning up unused account checks. - Device Health Oracle - Add new device-health-oracle component. See rfcs/rfc12-network-provisioning.md for details. +- Client + - Add `make install` make target. To build and deploy from source, users can now run `cd client && make build && make install` to install the doublezero and doublezerod binaries and the doublezerod systemd unit. ## [v0.8.2](https://github.com/malbeclabs/doublezero/compare/client/v0.8.1...client/v0.8.2) – 2025-01-13 diff --git a/client/INSTALL.md b/client/INSTALL.md index fa9087501..04022cea3 100644 --- a/client/INSTALL.md +++ b/client/INSTALL.md @@ -71,6 +71,7 @@ $ yum install doublezero-x.x.x Rust: ``` +$ sudo apt install libssl-dev pkg-config $ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ``` @@ -82,30 +83,18 @@ https://go.dev/doc/install # Checkout the latest stable version. You can find the latest stable version here: https://docs.malbeclabs.com/connect/ $ git checkout client/vX.X.X -# build the doublezero cli -$ cargo build --release --target-dir ./bin --manifest-path doublezero/Cargo.toml -$ mv bin/release/doublezero bin/. - -# build the doublezero daemon -$ CGO_ENABLED=0 go build -o bin/doublezerod doublezerod/cmd/doublezerod/main.go - -# The doublezero cli and the daemon communicate over a unix socket. Setup socket file directory and permissions -$ sudo mkdir /var/run/doublezerod -$ sudo chmod 700 /var/run/doublezerod -$ sudo chown $USER:$USER /var/run/doublezerod - -# Setup start directory where the DoubleZero daemon stores connection state: -$ sudo mkdir /var/lib/doublezerod -$ sudo chmod 700 /var/lib/doublezerod -$ sudo chown $USER:$USER /var/lib/doublezerod +$ cd client +$ make build ``` -The DoubleZero daemon requires CAP_NET_ADMIN and CAP_NET_RAW capabilities. CAP_NET_ADMIN capability is for the ability to create tunnel interfaces, add IP addressing and add routes to the kernel routing table via netlink. CAP_NET_RAW capability is used for latency probing via raw sockets: +### Install DoubleZero CLI/Daemon +After running the Build step above, install the doublezero and doublezerod binaries, and the doublezerod systemd unit, with the following commend: ``` -$ sudo setcap cap_net_raw,cap_net_admin=+ep ./bin/doublezerod - -$ getcap bin/doublezerod -doublezerod cap_net_admin,cap_net_raw=ep +$ make install +``` +To verify that the doublezerod service is runninng, run the following command: +``` +sudo systemctl status doublezerod ``` ### Network requirements diff --git a/client/Makefile b/client/Makefile index 7e72b50da..001d8c59b 100644 --- a/client/Makefile +++ b/client/Makefile @@ -18,12 +18,27 @@ lint: cargo clippy --manifest-path ./doublezero/Cargo.toml $(CLIPPY_FLAGS) golangci-lint run -c ../.golangci.yaml -.PHONY: build -build: - $(MAKE) lint -C doublezero - $(MAKE) lint -C doublezerod - .PHONY: build build: $(MAKE) build -C doublezero CARGO_FLAGS="$(CARGO_FLAGS)" $(MAKE) build -C doublezerod + +INSTALL_PREFIX ?= /usr +BINDIR ?= $(INSTALL_PREFIX)/bin +SYSTEMD_DIR ?= /usr/lib/systemd/system + +.PHONY: install +install: + @if ! getent group doublezero >/dev/null 2>&1; then \ + addgroup --system doublezero; \ + fi + @if ! getent passwd doublezero >/dev/null 2>&1; then \ + adduser --system --ingroup doublezero --no-create-home --home /nonexistent doublezero; \ + fi + install -d $(DESTDIR)$(BINDIR) + install -m 755 ../target/release/doublezero $(DESTDIR)$(BINDIR)/doublezero + install -m 755 doublezerod/bin/doublezerod $(DESTDIR)$(BINDIR)/doublezerod + install -d $(DESTDIR)$(SYSTEMD_DIR) + install -m 644 doublezerod/cmd/doublezerod/doublezerod.service $(DESTDIR)$(SYSTEMD_DIR)/doublezerod.service + systemctl daemon-reload + -systemctl unmask doublezerod.service