empeg-preinit v2

Posted by: wfaulk

empeg-preinit v2 - 26/03/2002 23:02

I'd noticed that people were actually using my empeg-preinit binary, so I thought I'd upgrade it to do some useful stuff.

This version adds the ability to wait on the music partitions to be mounted. This is accomplished by naming your script starting with a capital `M'. All scripts that need to run immediately now need to start with a capital `N'. This will break current scripts, as ones that start with neither an `N' nor an `M' will not be executed at all. Future releases will (hopefully) have a sorting mechanism so that one script can depend on another having been exectuted. Based on that, I would suggest that scripts have their second and third characters be a two digit number (a la ``N75telnetd'' or ``M33alarmclock'') so that future revisions can sort properly.

This new version also prints out the fact that it has started and has stopped. I would suggest that all scripts do the same thing. Something like this seems appropriate:
#!/bin/sh

echo -e "starting telnetd...\c"
/empeg/bin/telnetd
echo "done"
Of course, some error notification might also be useful, but I'll leave that up to script writers.

It is, as always available at http://www.beaglebros.com/empeg/empeg-preinit/.
Posted by: justinlarsen

Re: empeg-preinit v2 - 27/03/2002 00:26

thanks Bitt
Posted by: whitetrash

Re: empeg-preinit v2 - 27/03/2002 21:05

Just installed preinit and a very similar startup script for telnetd. I am a happy camper! No need to console in anymore. Woo-hoo!
Posted by: crazymelki

Re: empeg-preinit v2 - 28/03/2002 11:10

Hello Bitt,

I have there a question. With you earlier version of preinit I had it work with the viewer. Now I changed the name of the script file to "N12viewerinit" and have the follwing string there:

#!/bin/sh
echo -e "starting viewer...\c"
/empeg/bin/viewer/viewer
echo "done"

The viewer file is still in the /empeg/bin/viewer/ directory...

I did only not create the preinit.d directory because it was existing already....

any idea?

thanks
Posted by: wfaulk

Re: empeg-preinit v2 - 28/03/2002 16:47

And it doesn't work now? Odd.

I haven't played with the viewer app, so I don't know if it needs to wait for config.ini to be available or anything (I can't imagine that it does, since it worked with the old preinit).

Can you watch the serial port on boot and make sure that you see the output from preinit itself and from your script. And afterwards, can you run ``ps ax'' and see if you see the viewer app running?
Posted by: crazymelki

Re: empeg-preinit v2 - 28/03/2002 23:27

Hello Bitt,

Ok...I was watching the serial port!

During the boot I can see
empeg-preinit starting...
empeg-preinit complete

but then on the end there is an error:
No such file or directoryinit.d/M13empwake: /empeg/bin/empwake/empwake

I had the same error with the viewer. The files are there in this right diectory all with chmod 755. I did also check that the file names are in lower case letter. I use Hijack V251

any ideas? Can I delete the preinit.d directory and start the V2 form the scratch?

bye

Posted by: mtempsch

Re: empeg-preinit v2 - 28/03/2002 23:39

No such file or directoryinit.d/M13empwake: /empeg/bin/empwake/empwake

I had the same error with the viewer. The files are there in this right diectory all with chmod 755. I did also check that the file names are in lower case letter.


Any chance you created the file(s) on a windows system without saving as Unix style (in regard to linefeeds)? In that case it'll actually be looking for a file named /empeg/bin/empwake/empwake^M, as there's an extra Control-M (carriage return) character before the linefeed...

/Michael
Posted by: crazymelki

Re: empeg-preinit v2 - 28/03/2002 23:46

hello Michael,

Yeep. In the meantime I found it! But they was with the old preinit working in a windows style.. Not 100% sure. I changed the style now to Unix and it works fine..both viewer and empwake.

many thanks!

bye
Posted by: mtempsch

Re: empeg-preinit v2 - 29/03/2002 00:22

Hailing Tony, keeper of the FAQ:

This is starting to become a frequent "gotcha"... The FAQ touches upon the subject of Unix/Windows style linefeeds in a couple of places, but a new entry
"Why does it say it can't find my script/file" might be in order. This could also mention the fact that the current directory isn't automatically in the path, sensitivity to CapITalizAtion etc...

/Michael
Posted by: wfaulk

Re: empeg-preinit v2 - 29/03/2002 10:24

That's weird. I changed nothing in the code that actually executes the script. (In fact, it just calls /bin/sh to do it. My app never even looks at the data in the script file.) Did you add any commands to the script? If the call to your app was the last line in the script, then it might not have been followed by the errant Ctrl-M.
Posted by: crazymelki

Re: empeg-preinit v2 - 29/03/2002 10:57

Bitt,

I did first download the old script via FTP from my device. Then I did modify it with Ultraedit (normally there is a info message about conversion) as following:

#!/bin/sh
echo -e "starting viewer...\c"
/empeg/bin/viewer/viewer
echo "done"

I saved the file and uploaded it to my device.

that's what I did.

bye
Posted by: bonzi

Re: empeg-preinit v2 - 31/03/2002 13:48

Bitt, I am quite sure the new empeg-preinit executes only one each of M* and N* scripts (I have three - VNC, viewer and telnetd, and all can be N*, but I shuffled them around). All are executable, with Unix line terminators and essentially identical. I get echo only from one script from each group, and can verify (ps -ef) that really only those got started. By shuffling the scripts among groups I got them all to start at least once (that is, if a script is the only one in either N* or M* group, it gets started), so that would rule out the problem with scripts themselves. All 'illegally' named files got reported on console. I took a quick look at source, but could not see anything wrong (at least with the loop that reads the directory - I got only that far at the moment).

This is not a big deal, since I can wrap them all into one script, but I thought you would like to know...

BTW, thanks for this hack - I prefer to keep stock init
Posted by: wfaulk

Re: empeg-preinit v2 - 31/03/2002 18:02

I'm sure that that's my fault. It occurs to me that I never did check that multiple scripts actually worked.

Edit: Yeah. My whole linked list implementation is fucked. Man, it's been a long time. I'll have a fix tomorrow, most likely.
Posted by: wfaulk

empeg-preinit v3 - 31/03/2002 19:31

Okay. Now I've got it fixed. Still at http://www.beaglebros.com/empeg/empeg-preinit/
Posted by: tonyc

Re: empeg-preinit v3 - 31/03/2002 19:32

Is the numeric sorting implemented in this version?
Posted by: wfaulk

Re: empeg-preinit v3 - 31/03/2002 19:33

Nope. Is it something you need?

Edit: Although, in practice, you might be able to use the fact that readdir() seems to sort things itself by creation time, and create the scripts in the order you want them executed.
Posted by: tonyc

Re: empeg-preinit v3 - 31/03/2002 19:50

Edit: Although, in practice, you might be able to use the fact that readdir() seems to sort things itself by creation time, and create the scripts in the order you want them executed.

Good enough for me. I just wanted this:

N10usrmount: mounts my /usr partition (/dev/hda2)
N20myprog1: runs my program which resides on /usr

etc. Since my user programs all live on /usr I wanted to create one that executes first to mount it. The create time thing is fine for me.
Posted by: wfaulk

Re: empeg-preinit v3 - 31/03/2002 20:04

Well, what about making it a M* script? That will (should) wait until the drives are mounted before running the script.

Edit: Then again, you did say your /usr partition. Nevermind.
Posted by: bonzi

Re: empeg-preinit v3 - 01/04/2002 12:11

Works now. Thanks!