Pcileech/pcileech-build-sudo

25 lines
1012 B
Plaintext
Raw Permalink Normal View History

#!/bin/bash
# Wrapper script to run pcileech-generate with sudo while preserving Python path
#
# generate.py is the correct entry point that orchestrates:
# • Device enumeration and selection
# • Driver rebinding to vfio-pci
# • Container execution with build.py
# • Optional firmware flashing
# Get the path to the installed pcileech-generate script
PCILEECH_GENERATE_PATH=$(which pcileech-generate)
if [ -z "$PCILEECH_GENERATE_PATH" ]; then
echo "Error: pcileech-generate not found in PATH"
echo "Make sure pcileechfwgenerator is properly installed: pip install pcileechfwgenerator"
exit 1
fi
# Get Python site-packages directories
PYTHON_USER_SITE=$(python3 -m site --user-site)
PYTHON_SITE_PACKAGES=$(python3 -c "import site; print(':'.join(site.getsitepackages()))")
# Run with sudo, preserving the PYTHONPATH
echo "Running pcileech-generate with sudo and preserved Python paths..."
sudo PYTHONPATH="$PYTHONPATH:$PYTHON_USER_SITE:$PYTHON_SITE_PACKAGES" "$PCILEECH_GENERATE_PATH" "$@"