#!/bin/bash # Installation script for Strawberry Security Scanner set -e echo "=== Strawberry Security Scanner Installation ===" echo # Check if running as root if [ "$EUID" -ne 0 ]; then echo "Please run as root (sudo)" exit 1 fi # Access group: members can read findings and use the desktop app's controls # (reload rules, rescan). Nobody else can see the evidence. if ! getent group strawberry >/dev/null; then echo "Creating 'strawberry' group..." groupadd --system strawberry fi # Create directories. Rules are root-only (anyone who can edit them can blind # the scanner); evidence is readable by the strawberry group only. echo "Creating directories..." install -d -m 0755 /etc/strawberry install -d -m 0700 /etc/strawberry/rules install -d -m 0750 -g strawberry /var/lib/strawberry install -d -m 0750 -g strawberry /var/lib/strawberry/feeds # Evidence: a legacy database.db file (imported into the event store by the # daemon on its next start, old file kept as database.db.migrated-) or # the event store directory. Either way the strawberry group reads evidence; # telemetry/ stays root-only through its own 0700/0600 modes. f=/var/lib/strawberry/database.db if [ -f "$f" ]; then chgrp strawberry "$f" && chmod 0640 "$f" elif [ -d "$f" ]; then chgrp -R strawberry "$f" chmod 0750 "$f" [ -d "$f/evidence" ] && chmod 0750 "$f/evidence" fi # Copy configuration if [ -f "config/strawberry.conf" ]; then echo "Installing configuration..." if [ -f /etc/strawberry/strawberry.conf ]; then echo " keeping existing /etc/strawberry/strawberry.conf" else install -m 0644 config/strawberry.conf /etc/strawberry/strawberry.conf fi fi # Copy example YARA rules if [ -f "config/example_rules.yar" ]; then echo "Installing example YARA rules..." install -m 0600 config/example_rules.yar /etc/strawberry/rules/example_rules.yar fi # Install binary if [ -f "builddir/src/strawberry" ]; then echo "Installing binary..." install -m 0755 builddir/src/strawberry /usr/local/bin/strawberry else echo "Error: Binary not found. Please build first with 'meson compile -C builddir'" exit 1 fi # Install the eBPF exec monitor object (without it the daemon falls back to # slower procfs polling, which misses short-lived processes) if [ -f "builddir/src/process_monitor.bpf.o" ]; then echo "Installing eBPF object..." install -d -m 0755 /usr/local/share/strawberry install -m 0644 builddir/src/process_monitor.bpf.o /usr/local/share/strawberry/process_monitor.bpf.o else echo "Warning: builddir/src/process_monitor.bpf.o not found; the daemon will use procfs polling" fi # Desktop app + tray indicator (optional; built when Qt6 is available) if [ -f "builddir/app/strawberry-tray" ]; then echo "Installing desktop app..." install -m 0755 builddir/app/strawberry-tray /usr/local/bin/strawberry-tray install -d -m 0755 /usr/local/share/applications install -m 0644 packaging/strawberry-tray.desktop /usr/local/share/applications/strawberry-tray.desktop else echo "Note: builddir/app/strawberry-tray not built (needs Qt6); skipping the desktop app" fi # MCP server for agents (optional; built when nlohmann_json is available) if [ -f "builddir/mcp/strawberry-mcp" ]; then echo "Installing MCP server..." install -m 0755 builddir/mcp/strawberry-mcp /usr/local/bin/strawberry-mcp fi # Install systemd units: the scanner, plus the sandboxed rule updater # (daily timer + "Update now" path trigger). if [ -f "scripts/strawberry.service" ]; then echo "Installing systemd units..." install -m 0644 scripts/strawberry.service /etc/systemd/system/strawberry.service for unit in strawberry-update.service strawberry-update.timer strawberry-update.path; do install -m 0644 "scripts/$unit" "/etc/systemd/system/$unit" done systemctl daemon-reload # Pick up the new binary if the service is already running. systemctl try-restart strawberry || true echo "Enabling automatic YARA rule updates (daily)..." systemctl enable --now strawberry-update.timer strawberry-update.path # Fetch the default feed (YARA Forge core) now, in the background. systemctl start --no-block strawberry-update.service || true fi # OpenSnitch: containment rules can pin a binary by hash only when OpenSnitch # computes checksums. Offer to turn that on. if [ -f /etc/opensnitchd/default-config.json ] && [ -x /usr/local/bin/strawberry ]; then if grep -q '"EnableChecksums": *true' /etc/opensnitchd/default-config.json; then echo "OpenSnitch checksums already enabled (containment rules are hash-pinned)." elif [ -t 0 ]; then read -r -p "Enable OpenSnitch checksums so network containment is pinned to the exact binary? [Y/n] " answer if [ "$answer" != "n" ] && [ "$answer" != "N" ]; then /usr/local/bin/strawberry --opensnitch-enable-checksums /etc/strawberry/strawberry.conf \ && systemctl try-restart opensnitchd || true fi else echo "Tip: sudo strawberry --opensnitch-enable-checksums && sudo systemctl restart opensnitchd" fi fi # Offer to grant the invoking desktop user access. if [ -n "${SUDO_USER:-}" ] && [ "$SUDO_USER" != "root" ]; then if id -nG "$SUDO_USER" | tr ' ' '\n' | grep -qx strawberry; then echo "User '$SUDO_USER' is already in the strawberry group." elif [ -t 0 ]; then read -r -p "Add '$SUDO_USER' to the strawberry group (view findings, use controls)? [y/N] " answer if [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then usermod -aG strawberry "$SUDO_USER" echo "Added. Log out and back in for it to take effect." fi else echo "To use the desktop app: sudo usermod -aG strawberry $SUDO_USER (then log out/in)" fi fi echo echo "Installation complete!" echo echo "To start the scanner now and on every boot:" echo " sudo systemctl enable --now strawberry" echo echo "Rule updates: daily via strawberry-update.timer (first run started now)." echo " status: strawberry --policy logs: journalctl -u strawberry-update" echo echo "Configuration: /etc/strawberry/strawberry.conf" PROFILE=$(sed -n 's/^scan_profile=//p' /etc/strawberry/strawberry.conf 2>/dev/null | tail -1) echo "Scan profile: ${PROFILE:-balanced (default)} (efficient | balanced | aggressive;" echo " set scan_profile= in the config; matching systemd limits: systemctl edit strawberry)" echo "State/Data: /var/lib/strawberry/" echo "YARA Rules: /etc/strawberry/rules/" echo "Logs: journalctl -u strawberry" echo echo "Desktop app: launch 'Strawberry' from your app launcher, or start the tray" echo "indicator with your session. For sway, add to your sway config:" echo " exec strawberry-tray" if [ -f /usr/local/bin/strawberry-mcp ]; then echo echo "Agent access (MCP): register with Claude Code as your desktop user:" echo " claude mcp add strawberry -- strawberry-mcp" echo " (add --read-only after strawberry-mcp to allow queries only)" fi