Tiny Core Linux
Tiny Core Base => Raspberry Pi => Topic started by: risshuu on November 14, 2016, 09:28:36 AM
-
I am trying to run the following command on startup.
sudo -u bob -H python /home/bob/fauxmo.py
I am running piCore v 8.0. I am not using a desktop environment.
I can run the code above as root no problem, but it will not run it when I put it in /opt/bootlocal.sh.
How can I get this to run every time the machine is started?
Thanks
-
Omit the sudo part, as bootlocal.sh already runs with root privileges.
-
Does user bob and /home/bob exists?
-
Misalf: I don't want it run as 'root', I want it to run as 'bob'.
bmarkus: Yes, the user and his home directory exists. I can run the command as root with no problem after the machine has started up. I want this to run every time I turn on/reboot the machine. I want it to run as 'bob', and not root.
I can't think of any other way of doing it.
Thanks
-
TCUSER="$(cat /etc/sysconfig/tcuser)"
su "$TCUSER" -c "python /home/bob/fauxmo.py"
-
Misalf: Thank you for the reply :D. It does work, but I wanted to run it as a different user that I created on the box, not as tc.
:-\
Any other ideas?
-
/etc/sysconfig/tcuser contains the current user name, not necessarily tc .
You can use the user= boot code to change that.
Otherwise,
su bob -c "python /home/bob/fauxmo.py"
should work.
-
Thank you! I set "bob" up as a system account so it wasn't working because he had no default shell (afaict). I just added
-s /bin/bash
to the code you gave me and it looks like it works.
Thank you so much!
-
Looks like I spoke too soon. While it did run at the cli when run as root, it did not run when I restarted my pi.
Thanks for the help, though.