Tiny Core Linux

Tiny Core Base => TCB Q&A Forum => Topic started by: christully on January 22, 2019, 07:58:25 AM

Title: Run a script as soon as TC boots
Post by: christully on January 22, 2019, 07:58:25 AM
So, Google lead me to this:

http://forum.tinycorelinux.net/index.php/topic,6783.msg35691.html#msg35691

from which I gather that many years ago, the accepted method to do what I want to do is to put a simple script in ~/.X.d

I have done that:

/home/tc/.X.d/menu
Code: [Select]
#! /bin/bash

source /opt/bin/menu.sh

/opt/bin/menu.sh does exist and is part of core.gz (added by me), and runs if I just type menu.sh at the command line. And, i have just tested that from the command line I can type ~/.X.d/menu and get the result I expect.

So, my analysis is that my script in ~/.X.d is being ignored?

Or, Am I going about this all wrong?
Title: Re: Run a script as soon as TC boots
Post by: Rich on January 22, 2019, 08:12:11 AM
Hi christully
Try changing the script in ~/.X.d to just:
Code: [Select]
/opt/bin/menu.sh &
Title: Re: Run a script as soon as TC boots
Post by: Rich on January 22, 2019, 08:33:21 AM
Hi christully
Or does your program need a terminal to execute? Then maybe something like this:
Code: [Select]
exec cliorx /opt/bin/menu.sh &
Title: Re: Run a script as soon as TC boots
Post by: christully on January 22, 2019, 10:17:11 AM
Hi Rich,

Thanks for the suggestions!

Option 1 - no dice...  Trying Option 2... also no dice...

Both options just dump me at the command line. I've tried several variations on the options you posted, including making sure that the file is owned by tc.

If I manually execute the ~/.X.d/menu file in either configuration that you posted, my scripts run. But none of the variations I have tried get it to run on boot.

:puzzled:
Title: Re: Run a script as soon as TC boots
Post by: christully on January 22, 2019, 10:27:53 AM
And, I think I may know why the ~/.X.d/ option is not working for me. From the wiki:

http://wiki.tinycorelinux.net/wiki:the_boot_process (http://wiki.tinycorelinux.net/wiki:the_boot_process)
Quote
#.xsession
…the file ”.xsession” in /home/tc, is called. It starts X, the X desktop, and also autostarts any custom scripts in /home/tc/.X.d.

I don't even have X installed.  I am working with a "Core" install of TC.  No GUI, just CLI.
Title: Re: Run a script as soon as TC boots
Post by: Rich on January 22, 2019, 10:31:32 AM
Hi christully
Then place the command at the end of your  /opt/bootlocal.sh  file.
Title: Re: Run a script as soon as TC boots
Post by: christully on January 22, 2019, 12:37:14 PM
Rich -  :)

That worked... But not quite.

My script runs but does not pause for user input like it is supposed to.  Instead it just quits and drops me back at the command prompt.

Chris
Title: Re: Run a script as soon as TC boots
Post by: Rich on January 22, 2019, 12:48:21 PM
Hi christully
Then try it like this at the end of your  bootlocal.sh:
Code: [Select]
/opt/bin/menu.sh
Title: Re: Run a script as soon as TC boots
Post by: coreplayer2 on January 22, 2019, 04:52:38 PM
Hi Rich.  Is it possible the interactive script is expecting BASH and bash is not installed?

Just a thought..


Sent from my iPhone using Tapatalk
Title: Re: Run a script as soon as TC boots
Post by: Rich on January 22, 2019, 05:04:29 PM
Hi coreplayer2
I don't think so. He said:
... If I manually execute the ~/.X.d/menu file in either configuration that you posted, my scripts run. ...
I think what may be happening is his menu script was being backgrounded and control was returned to bootlocal.sh instead
of waiting for input. I think that explains this result:
... My script runs but does not pause for user input like it is supposed to.  Instead it just quits and drops me back at the command prompt. ...
Title: Re: Run a script as soon as TC boots
Post by: curaga on January 23, 2019, 12:37:48 AM
For command-line scripts that expect user input, try ~/.profile. It gets executed on the tc user login.
Title: Re: Run a script as soon as TC boots
Post by: christully on January 23, 2019, 09:32:59 AM
Rich-

Thanks for the suggestions of why things are working the way they are - that makes sense.

curaga-

I will try that now!
Title: Re: Run a script as soon as TC boots
Post by: christully on January 23, 2019, 09:58:50 AM
And an update- curaga's suggestion worked like a charm!

I just added:

Code: [Select]
/opt/bin/menu.sh[\code]

to the end of my ~/.profile and my script runs like I expect it to run.

THANK YOU