Base working for damage

This commit is contained in:
2026-10-09 23:10:40 -06:00
parent 2895be91c4
commit 3e0ad62cf2
31 changed files with 9758 additions and 67 deletions
+55
View File
@@ -0,0 +1,55 @@
#!/bin/sh
# Grant the Python interpreter the capabilities required to capture network
# traffic, so that Albion Online Stats does not have to run as root.
#
# Usage: fixlibpcap.sh [path-to-python-interpreter]
PYTHON="${1:-$(command -v python3)}"
if [ -z "$PYTHON" ]; then
echo "Could not determine the python interpreter path." >&2
exit 1
fi
if [ ! -x "$PYTHON" ]; then
echo "Python interpreter '$PYTHON' is not executable." >&2
exit 1
fi
# Resolve symlinks (e.g. venv/bin/python -> /usr/bin/python3). setcap has to be
# applied to the real binary, not to a symlink.
if readlink -f "$PYTHON" >/dev/null 2>&1; then
PYTHON="$(readlink -f "$PYTHON")"
elif command -v python3 >/dev/null 2>&1; then
PYTHON="$(python3 -c 'import os, sys; print(os.path.realpath(sys.executable))' 2>/dev/null || echo "$PYTHON")"
fi
if ! command -v setcap >/dev/null 2>&1; then
echo "The 'setcap' tool was not found." >&2
echo "Install libcap before retrying:" >&2
echo " Debian/Ubuntu: sudo apt install libcap2-bin" >&2
echo " Fedora: sudo dnf install libcap" >&2
echo " Arch: sudo pacman -S libcap" >&2
exit 1
fi
echo "Granting packet capture capabilities to: $PYTHON"
echo "You may be asked for a password."
# pkexec shows a graphical authentication dialog, which works even when the app
# was not started from a terminal. Fall back to sudo otherwise.
if command -v pkexec >/dev/null 2>&1; then
pkexec setcap cap_net_raw,cap_net_admin=eip "$PYTHON"
status=$?
else
sudo setcap cap_net_raw,cap_net_admin=eip "$PYTHON"
status=$?
fi
if [ "$status" -ne 0 ]; then
echo "Failed to set capture capabilities. Try running the app with sudo:" >&2
echo " sudo $(command -v aostats 2>/dev/null || echo 'python -m aostats')" >&2
exit "$status"
fi
echo "Done. Please restart Albion Online Stats."