Tiny Core Linux

Tiny Core Base => Raspberry Pi => Topic started by: risshuu on November 14, 2016, 09:28:36 AM

Title: Command not running on startup
Post by: risshuu on November 14, 2016, 09:28:36 AM
I am trying to run the following command on startup.
Code: [Select]
sudo -u bob -H python /home/bob/fauxmo.pyI 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
Title: Re: Command not running on startup
Post by: Misalf on November 14, 2016, 09:37:50 AM
Omit the  sudo  part, as  bootlocal.sh  already runs with root privileges.
Title: Re: Command not running on startup
Post by: bmarkus on November 14, 2016, 12:03:53 PM
Does user bob and /home/bob exists?
Title: Re: Command not running on startup
Post by: risshuu on November 14, 2016, 06:30:55 PM
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
Title: Re: Command not running on startup
Post by: Misalf on November 14, 2016, 09:33:48 PM
Code: [Select]
TCUSER="$(cat /etc/sysconfig/tcuser)"
su "$TCUSER" -c "python /home/bob/fauxmo.py"
Title: Re: Command not running on startup
Post by: risshuu on November 15, 2016, 01:09:49 AM
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?
Title: Re: Command not running on startup
Post by: Misalf on November 15, 2016, 02:09:52 AM
/etc/sysconfig/tcuser  contains the current user name, not necessarily  tc .
You can use the  user=  boot code to change that.
Otherwise,
Code: [Select]
su bob -c "python /home/bob/fauxmo.py"
should work.
Title: Re: Command not running on startup
Post by: risshuu on November 16, 2016, 01:05:43 AM
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
Code: [Select]
-s /bin/bash to the code you gave me and it looks like it works.

Thank you so much!
Title: Re: Command not running on startup
Post by: risshuu on November 16, 2016, 02:07:47 AM
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.