Instantly share code, notes, and snippets.

Embed
What would you like to do?
Run Python as Root
#!/usr/bin/env bash
DIR=$(dirname $(readlink -f "${BASH_SOURCE}"))
if [ ! -f $DIR/venv/bin/python ]; then
echo "This script should be located in the project root directory"
echo "and the virtual environment should be created."
else
# Change python back to run as pi
sudo chown -v pi:pi "$DIR/venv/bin/python"
sudo chmod -v u-s "$DIR/venv/bin/python"
fi
#!/usr/bin/env bash
DIR=$(dirname $(readlink -f "${BASH_SOURCE}"))
if [ ! -f $DIR/venv/bin/python ]; then
echo "This script should be located in the project root directory"
echo "and the virtual environment should be created."
else
# Change python to run as root
sudo chown -v root:root "$DIR/venv/bin/python"
sudo chmod -v u+s "$DIR/venv/bin/python"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment