I have an install script to set up dependencies for a project, this means installing packages using pip and apt.
My prefered method is to run the script as sudo ./install but then how do I drop sudo for pip (do I need to with --user)?
#!/bin/sh
if [ $(id -u) -ne 0 ]; then
echo Please run as root
exit
fi
apt install pkg_a pkg_b pkg_c
# Is this fine? How do I drop sudo here?
pip install --user pkg_d pkg_e pkg_f
The alternative is to have sudo in the script but I prefer the first option if it's possible
#!/bin/sh
sudo apt install pkg_a pkg_b pkg_c
pip install --user pkg_d pkg_e pkg_f