Skip to content

Instantly share code, notes, and snippets.

@nathanpjones
Created February 21, 2016 20:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathanpjones/61680827d180e930848d to your computer and use it in GitHub Desktop.
Save nathanpjones/61680827d180e930848d to your computer and use it in GitHub Desktop.
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