Startup folder - what order of actions?[Solved]

Using applications, configuring, problems
Post Reply
Message
Author
User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

Startup folder - what order of actions?[Solved]

#1 Post by greengeek »

How does the operating system choose the "action order" of items placed in the /root/Startup folder? Does it decide based on alphabetical name, or file size/date or maybe some other determinant?

I want to action several scripts one after the other (but without writing them inside one single script).

If I can change the order of actioning just by changing the filename that would be quite easy.
Last edited by greengeek on Thu 25 Oct 2012, 17:28, edited 1 time in total.

User avatar
ETP
Posts: 1193
Joined: Tue 19 Oct 2010, 19:55
Location: UK

Startup folder - what order of actions?

#2 Post by ETP »

Hi greengeek,

No idea about the order but you could just place one script in the folder who's
function is purely to call other scripts held outside the startup folder - a calling script.

You can then specify the order and include any necessary sleep commands.
Regards ETP
[url=http://tinyurl.com/pxzq8o9][img]https://s17.postimg.cc/tl19y14y7/You_Tube_signature80px.png[/img][/url]
[url=http://tinyurl.com/kennels2/]Kennels[/url]

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#3 Post by SFR »

Not sure if it's utilized in the same manner in all Puppies, but in Slacko (and Lupu IIRC) the job is done by the end portion of "delayedrun" script in /usr/sbin.
It looks like:

Code: Select all

if [ -d /root/Startup ];then
 for a in /root/Startup/*
 do
  [ -x "$a" ] && "$a" &
  sleep 0.2
 done
fi
I just checked for sure and the output is alphabetical.

Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#4 Post by rcrsn51 »

SFR wrote:I just checked for sure and the output is alphabetical.
But because the programs in Startup are being sent into the background, I don't think that you can guarantee that script #1 is completed before script #2 starts.
but you could just place one script in the folder who's function is purely to call other scripts held outside the startup folder - a calling script. You can then specify the order and include any necessary sleep commands.
But that should work.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#5 Post by sunburnt »

Hi greengeek; The one script idea is a good one.

My experience is that the order is alphabetic, numbers first.

So like this:

0_script1
1_script2
2_script3


P.S. What`s your thoughts on a PXE server?
Last edited by sunburnt on Wed 10 Oct 2012, 23:11, edited 2 times in total.

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#6 Post by 01micko »

rcrsn51 wrote:
SFR wrote:I just checked for sure and the output is alphabetical.
But because the programs in Startup are being sent into the background, I don't think that you can guarantee that script #1 is completed before script #2 starts.
Correct.

=========

Actually, /root/Startup is a bad idea and implemented wrong anyway. It spawns new processes of delayedrun which linger, eating valuable memory. Jamesbond solved this part.

Code: Select all

#this goes in /usr/sbin/delayedrun
if [ -d /root/Startup ];then
 for a in /root/Startup/*
 do
  if [ -x "$a" ];then $a & #jamesbond
  fi
  sleep 0.2
 done
fi
That code is from the current slacko beta.

---------

Note that a more efficient way to do this is to let your WM/DE handle this and usually they require a special cutdown .desktop file, however, for JWM you can put entries like this in a file in $HOME/.jwm/jwmstartuprc and "include" it in your jwm startup routine.

Code: Select all

<StartupCommand>/path/to/command</StartupCommand>
Trouble is, there are so many progs hard coded to /root/startup that this approach with Puppy becomes impractical.
Puppy Linux Blog - contact me for access

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#7 Post by SFR »

greengeek wrote:I want to action several scripts one after the other[...]
SFR wrote: [ -x "$a" ] && "$a" &
rcrsn51 wrote:But because the programs in Startup are being sent into the background, I don't think that you can guarantee that script #1 is completed before script #2 starts.
Good point! :oops: 8)

@Mick:
Are there any contraindications to double quote the second "$a", because as it is now, scripts with spaces in filename won't be executed?

Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#8 Post by 01micko »

SFR wrote:--scripts with spaces in filename--
I sincerely hope there is no such thing!
Puppy Linux Blog - contact me for access

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#9 Post by SFR »

01micko wrote:
SFR wrote:--scripts with spaces in filename--
I sincerely hope there is no such thing!
Not script itself, but...
http://www.murga-linux.com/puppy/viewto ... 359#653359

Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#10 Post by 01micko »

SFR

That is BAD! :lol:

Not even MS Windows put spaces in their executable files, not the ones I've seen anyway.

I will not be wrapping $a in quotes to appease poor design.

-------------------------------------

greengeek

It would be helpful if you let us know what you want to start. There are more ways to start programs than the startup folder but they may depend on what else they need running to start.

You can start programs very early with a service script, which in Puppy are located @ /etc/init.d/ and started with a "start" parameter and stopped with a "stop" parameter and can have restart, reload, whatever other parameters depending on what they do. Similarly, these are executed in numerical, then alphabetical order.

You can also start stuff from /etc/rc.d/rc.local where in Puppy the firewall (if configured) gets started.

If you need something started that depends on network connectivity then you can construct a loop to detect when the net is up and start your proggy then. This can be done from any of the methods mentioned. You can do something similar if your proggy depends on X or rox or whatever.
Puppy Linux Blog - contact me for access

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#11 Post by greengeek »

.
Wow, thank you all for the feedback!
sunburnt wrote:P.S. What`s your thoughts on a PXE server?
The PXE server is complete (at least my first attempt at it is done) see here:
http://www.murga-linux.com/puppy/viewto ... 0&start=13
I’ve set it up to offer Thin Slacko to any PC that requests a PXE load.
However, it taught me that there is a lot to learn about remastering, and I think there is some improvement needed, which has led to some of these other questions. (also that is the reason for the mnt-all2 code I was asking you about...)
ETP wrote:you could just place one script in the folder who's
function is purely to call other scripts held outside the startup folder - a calling script.
Thanks. I will probably use this idea for some purposes. The downside that comes to mind is that it is not easy to spot what is going on just by having a quick look into the startup folder. It requires a closer look at the script each time I want to see what I have set up.
SFR wrote:Not sure if it's utilized in the same manner in all Puppies, but in Slacko (and Lupu IIRC) the job is done by the end portion of "delayedrun" script in /usr/sbin.
just checked for sure and the output is alphabetical.
sunburnt wrote:My experience is that the order is alphabetic, numbers first.
0_script1
1_script2
2_script3
Thank you both for clarifying that. That will make it easy to trial the outcome of various startup scripts.
rcrsn51 wrote:But because the programs in Startup are being sent into the background, I don't think that you can guarantee that script #1 is completed before script #2 starts.
Hmmm, I will have to be careful with that.
technosaurus wrote:Actually, /root/Startup is a bad idea and implemented wrong anyway. It spawns new processes of delayedrun which linger, eating valuable memory.
How long will those delayedrun processes stick around? Do they ever terminate?
Note that a more efficient way to do this is to let your WM/DE handle this
I am assuming WM is window manager, but I what is DE?
technosaurus wrote:
SFR wrote:--scripts with spaces in filename--
I sincerely hope there is no such thing!
Ok, I’m getting the feeling it’s a bad idea if I put spaces in the filename of a script??
It would be helpful if you let us know what you want to start. There are more ways to start programs than the startup folder but they may depend on what else they need running to start.
Actually I’m not totally sure yet exactly what I will need to run. I have been trying to remaster PupServer435 to add PXE server capability and I have discovered that various bits of functionality disappear when using the default remaster utility, so I have a need to force some scripts to run after booting. The real answer for me is to overcome the remaster problems, but using the startup folder seems to be a suitable short-term way to re-introduce the functions I have lost (which seems to include usb detection and automount for some devices..)

My final goal is to have a lightweight server (including PXE server ability) which will run ok on the older laptops that I find no longer have enough grunt to be good web surfing machines. (In particular one of these servers will be solar powered - booting itself when the sun comes up and going to sleep when the batteries go flat after dark). I want to trial various puppies as a base, and various puppies as the PXE offering. Once I have sorted out how to remaster properly I hope to make a whole stable of HomeFileserver/PXE pups which self-start without human intervention.

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#12 Post by SFR »

greengeek wrote:
technosaurus wrote:
SFR wrote:--scripts with spaces in filename--
I sincerely hope there is no such thing!
Ok, I’m getting the feeling it’s a bad idea if I put spaces in the filename of a script??
Yup, it's not a good practice indeed...

Until I saw that, I was ready to echo Mick's:
I sincerely hope there is no such thing!
My point was that it happens anyway. :roll:

Have a good day & Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#13 Post by greengeek »

SFR wrote:Until I saw that, I was ready to echo Mick's:
I sincerely hope there is no such thing!
My point was that it happens anyway. :roll:
What will happen if I DO have a space in the filename? Will it still run ok if it is a "standalone" script? Does the space only cause problems if the script is "called" by some other script/programme?

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#14 Post by 01micko »

greengeek wrote:What will happen if I DO have a space in the filename?
Nothing. But you may find that your conscience will get the better of you.

The only acceptable instances of spaces in filenames are names of actual files that are used by a program, say an mp3 file, an avi file a document. But still this can be a pain in the a*se even in Windows. Whenever that file is called it will always have to be wrapped in quotes. The genii at MS even decide to put spaces in directory, sorry "folder" names to trip even themselves up.

And forget Mac devs.. do you believe they put spaces in the filename of network shares? They do. we'll give them an extra i, geniii[!] :shock: ..probably why my wife likes her Mac, her name is Kriista.. yes 2 "i" 's, (no spaces though).
Puppy Linux Blog - contact me for access

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#15 Post by greengeek »

Two "ii"s is tolerable I suppose, but 3 "iii"s is just darn pretentious. Actually, maybe even two ii's is a little bit pretentious...
:-)

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#16 Post by greengeek »

01micko wrote:Nothing. But you may find that your conscience will get the better of you.
Dammit. (cue sound of palm slapping forehead.) Just spent half an hour trying to work out what was happening with my startup script then realised I had renamed it with spaces in the name. Doh!

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#17 Post by greengeek »

01micko wrote:It would be helpful if you let us know what you want to start. There are more ways to start programs than the startup folder but they may depend on what else they need running to start.
One of the things I want to do is run a script to connect wireless in pUPnGO. I've got it working by placing my script in /startup but was hoping to get it actioned earlier during the boot.
http://208.109.22.214/puppy/viewtopic.p ... &start=136
You mentioned the rc.local file but this pUPnGO does not seem to have one.

Any suggestions about where to put the wireless script so as to connect early but without undue risk?

User avatar
Keef
Posts: 987
Joined: Thu 20 Dec 2007, 22:12
Location: Staffordshire

#18 Post by Keef »

greengeek

pupngo does have rc.local in etc/rc.d/

I start my own wifi startup script from there and it works fine.

(you might be being tricked by the icon!)

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#19 Post by 8-bit »

As an alternative to using spaces in a file name, if your point is for easy identification of the file, why not use the underline character in place of the space?

I have seen instances of when using a space that it gets changed to %20 in the filename when it is accessed.

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#20 Post by greengeek »

Keef wrote:pupngo does have rc.local in etc/rc.d/
I start my own wifi startup script from there and it works fine.
Oh yeah. Duh. How'd i miss that?? Any chance of posting your rc.local in the pupngo2012 topic so I can work out where best to put my script? cheers

@8-bit:Underscore sounds good. Will do. Making long descriptive filenames with spaces is a bad habit of mine unfortunately. Thx.

Post Reply