navka -> lesavka migration

This commit is contained in:
Brad Stein 2025-06-23 00:26:02 -05:00
parent 208e7e4447
commit 90b23145b6
3 changed files with 69 additions and 36 deletions

View File

@ -12,7 +12,7 @@ sudo rustup default stable
sudo -u "$ORIG_USER" rustup default stable
# 3. clone / update into a user-writable dir
SRC="$HOME/.local/src/navka"
SRC="$HOME/.local/src/lesavka"
if [[ -d $SRC/.git ]]; then
sudo -u "$ORIG_USER" git -C "$SRC" pull --ff-only
else
@ -23,10 +23,10 @@ fi
sudo -u "$ORIG_USER" bash -c "cd '$SRC/client' && cargo clean && cargo build --release"
# 5. install binary
sudo install -Dm755 "$SRC/client/target/release/navka-client" /usr/local/bin/navka-client
sudo install -Dm755 "$SRC/client/target/release/lesavka-client" /usr/local/bin/lesavka-client
# 6. systemd service for system scope: /etc/systemd/system/navka-client.service
sudo tee /etc/systemd/system/navka-client.service >/dev/null <<'EOF'
# 6. systemd service for system scope: /etc/systemd/system/lesavka-client.service
sudo tee /etc/systemd/system/lesavka-client.service >/dev/null <<'EOF'
[Unit]
Description=Navka Client
After=network-online.target
@ -41,7 +41,7 @@ Environment=RUST_LOG=debug
Environment=NAVKA_DEV_MODE=1
Environment=NAVKA_SERVER_ADDR=http://64.25.10.31:50051
ExecStart=/usr/local/bin/navka-client
ExecStart=/usr/local/bin/lesavka-client
Restart=no
[Install]
@ -50,5 +50,5 @@ EOF
# 7. Call the *user* instance inside the callers session
sudo systemctl daemon-reload
sudo systemctl enable --now navka-client.service
sudo systemctl restart navka-client || true
sudo systemctl enable --now lesavka-client.service
sudo systemctl restart lesavka-client || true

View File

@ -3,22 +3,49 @@
set -euo pipefail
ORIG_USER=${SUDO_USER:-$(id -un)}
# 1. base packages (Arch + yay if missing)
echo "==> 1a. Base packages"
sudo pacman -Syq --needed --noconfirm git rustup protobuf gcc pipewire pipewire-pulse tailscale base-devel
if ! command -v yay >/dev/null 2>&1; then
echo " installing yay from AUR ..."
echo "==> 1b. installing yay from AUR ..."
sudo -u "$ORIG_USER" bash -c '
cd /tmp && git clone --depth 1 https://aur.archlinux.org/yay.git &&
cd yay && makepkg -si --noconfirm'
fi
# 2. Rust tool-chain for both accounts
echo "==> 2a. GC311 kerneldriver tweaks"
cat <<'EOF' | sudo tee /etc/modprobe.d/gc311-stream.conf >/dev/null
options uvcvideo quirks=0x200 timeout=10000
EOF
sudo /usr/bin/modprobe -r uvcvideo || true
sudo /usr/bin/modprobe uvcvideo
echo "==> 2b. Predictable /dev names for each capture card"
sudo tee /etc/udev/rules.d/85-gc311.rules >/dev/null <<'RULES'
# Serial 5313… RIGHT eye (video index 0)
SUBSYSTEM=="video4linux", ATTRS{idVendor}=="07ca", ATTRS{idProduct}=="3311", \
ATTRS{serial}=="5313550401897", ATTR{index}=="0", \
ATTRS{bInterfaceNumber}=="00", \
SYMLINK+="lesavka_r_eye"
# Serial 1200… LEFT eye (video index 0)
SUBSYSTEM=="video4linux", ATTRS{idVendor}=="07ca", ATTRS{idProduct}=="3311", \
ATTRS{serial}=="1200655409098", ATTR{index}=="0", \
ATTRS{bInterfaceNumber}=="00", \
SYMLINK+="lesavka_l_eye"
RULES
sudo udevadm control --reload
sudo udevadm trigger --subsystem-match=video4linux
udevadm settle
echo "==> 3. Rust toolchain"
sudo rustup default stable
sudo -u "$ORIG_USER" rustup default stable
# 3. writable build tree under /var/src (create once, chown to user)
SRC_DIR=/var/src/navka
REPO_URL=ssh://git@scm.bstein.dev:2242/brad_stein/navka.git
echo "==> 4a. Source checkout"
SRC_DIR=/var/src/lesavka
REPO_URL=ssh://git@scm.bstein.dev:2242/brad_stein/lesavka.git
if [[ ! -d $SRC_DIR ]]; then
sudo mkdir -p /var/src
sudo chown "$ORIG_USER":"$ORIG_USER" /var/src
@ -29,47 +56,53 @@ else
sudo -u "$ORIG_USER" git clone "$REPO_URL" "$SRC_DIR"
fi
# 4. build (as the normal user avoids root-owned Cargo.lock)
echo "==> 4b. Source build"
sudo -u "$ORIG_USER" bash -c "cd '$SRC_DIR/server' && cargo clean && cargo build --release"
# 5. install payload
sudo install -Dm755 "$SRC_DIR/server/target/release/navka-server" /usr/local/bin/navka-server
sudo install -Dm755 "$SRC_DIR/scripts/navka-core.sh" /usr/local/bin/navka-core.sh
echo "==> 5. Install binaries"
sud install -Dm755 "$SRC_DIR/server/target/release/lesavka-server" /usr/local/bin/lesavka-server
sudo install -Dm755 "$SRC_DIR/scripts/lesavka-core.sh" /usr/local/bin/lesavka-core.sh
# 6. systemd units
cat <<'UNIT' | sudo tee /etc/systemd/system/navka-core.service >/dev/null
echo "==> 6a. Systemd units - lesavka-core"
cat <<'UNIT' | sudo tee /etc/systemd/system/lesavka-core.service >/dev/null
[Unit]
Description=Navka USB gadget bring-up
Description=lesavka USB gadget bring-up
After=sys-kernel-config.mount
Requires=sys-kernel-config.mount
[Service]
Type=oneshot
ExecStart=/usr/local/bin/navka-core.sh
ExecStart=/usr/local/bin/lesavka-core.sh
RemainAfterExit=yes
CapabilityBoundingSet=CAP_SYS_ADMIN
MountFlags=slave
[Install]
WantedBy=multi-user.target
UNIT
cat <<'UNIT' | sudo tee /etc/systemd/system/navka-server.service >/dev/null
echo "==> 6b. Systemd units - lesavka-server"
cat <<'UNIT' | sudo tee /etc/systemd/system/lesavka-server.service >/dev/null
[Unit]
Description=Navka gRPC relay
After=network.target navka-core.service
Description=lesavka gRPC relay
After=network.target lesavka-core.service
[Service]
ExecStart=/usr/local/bin/navka-server
ExecStart=/usr/local/bin/lesavka-server
Restart=always
Environment="RUST_LOG=navka_server=trace"
Environment="RUST_LOG=lesavka_server=trace"
User=root
[Install]
WantedBy=multi-user.target
UNIT
echo "==> 6c. Systemd units - initialization"
sudo systemctl daemon-reload
sudo systemctl enable --now navka-core
sudo systemctl restart navka-core
echo "✅ navka-core installed and restarted..."
sudo systemctl enable --now lesavka-core
sudo systemctl restart lesavka-core
echo "✅ lesavka-core installed and restarted..."
sudo systemctl enable --now navka-server
sudo systemctl restart navka-server
echo "✅ navka-server installed and restarted..."
sudo systemctl enable --now lesavka-server
sudo systemctl restart lesavka-server
echo "✅ lesavka-server installed and restarted..."

View File

@ -1,9 +1,9 @@
#!/usr/bin/env bash
# navka-core.sh - background stealth daemon to present gadget as usb hub of genuine devices
# lesavka-core.sh - background stealth daemon to present gadget as usb hub of genuine devices
# Proven Pi-5 configfs gadget: HID keyboard+mouse
# Still need Web Cam Support + stereo UAC2
# navka-core one-shot gadget bring-up for Pi-5 / Arch-ARM
# lesavka-core one-shot gadget bring-up for Pi-5 / Arch-ARM
set -euo pipefail
# 1) Ensure the dwc2 peripheral overlay is active exactly once
@ -16,7 +16,7 @@ modprobe libcomposite || { echo "libcomposite not in kernel; abort" >&2; exit 1;
# 3) Mount configfs once
mountpoint -q /sys/kernel/config || mount -t configfs none /sys/kernel/config
G=/sys/kernel/config/usb_gadget/navka
G=/sys/kernel/config/usb_gadget/lesavka
# 4) Tear down any previous half-built gadget
if [[ -d $G ]]; then
@ -77,4 +77,4 @@ ln -s $G/functions/hid.usb1 $G/configs/c.1/
# 7) Finally bind to first available UDC
echo $(ls /sys/class/udc | head -n1) > $G/UDC
echo "[navka-core] gadget ready (keyboard on hidg0, mouse on hidg1)"
echo "[lesavka-core] gadget ready (keyboard on hidg0, mouse on hidg1)"