function after user creation
djsftree opened this issue · comments
Hi!
https://github.com/pyavitz/rpi-img-builder/tree/master/files/userscripts
Could you add a function called after the user creation script? I wish copy some items into the user home folder.
sure. give me a bit.
perfect! thanks!
Yeap. No prob.
What would be the best way of running pip as the installed user?
apt install -y python3-dev python3-pip python3-pytest procps libprocps-dev net-tools
as user
python3 -m pip install setuptools wheel
python3 -m pip install psutil==5.9.0 --no-binary :all:
Inside the chroot? Hmm. Not sure and it sounds risky. I use pip3 sparingly and when I do I use sudo
. Which they say is not recommended, but I've never had a game changing moment.
I have a thought. let me test.
I shoe horned it in, but it should also work with the user script function. Do a git pull
and add the following to ur script...
apt install -y python3-dev python3-pip python3-pytest procps libprocps-dev net-tools
sudo -u ${USERNAME} python3 -m pip install setuptools wheel
sudo -u ${USERNAME} python3 -m pip install psutil==5.9.0 --no-binary :all:
If you wanna be 100% you own it afterward: chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}
result:
ls p2/home/${USERNAME}/.local/lib/python*/site*
psutil psutil-5.9.0.egg-info
EDIT: Another possible solution could be.
su - ${USERNAME} -c "python3 -m pip install setuptools wheel"
su - ${USERNAME} -c "python3 -m pip install psutil==5.9.0 --no-binary :all:"
Or look into using the runuser command: https://man7.org/linux/man-pages/man1/runuser.1.html
closing because of inactivity