my first useful empeg program: Starter

Posted by: siberia37

my first useful empeg program: Starter - 06/02/2002 22:29

After a bit of futzing I came up with what I think is/will be a useful empeg program. It's a Starter program which starts (hopefully) other userland apps, this is useful in the case that you use a userland app only occasionally, so you don't want to add it to your startup script, thus slowing boot times and taking valuable memory. The idea of the Starter program is that it only starts programs when you need them. Basically you provide it a configuration file and for each entry it will bind to the hijack menu and provide you with a way of starting the program you want. I've attached the source, and an example configuration program.
So far the only program I've been able to start is empegVNC, I'm trying to start EmpTriv but it needs it's current directory to be where it's installed and unfortunately I can't figure out how to make a script to change the working directory.. it just keeps says "Invalid file or directory" when I do a "cd /drive0/var/emptriv" in the script, even though this works at the prompt itself.. any ideas anyone (I'm not smart with linux btw)? Make sure to start this program with a '&' at the end, and all programs in the script file should have the '&' too of course.
Posted by: wfaulk

Re: my first useful empeg program: Starter - 07/02/2002 10:09

/drive0 won't be mounted when you're trying to do this. You'll have to manually mount the filesystem and then unmount it afterwards, so as not to confuse the process that eventually gets around to mounting it.
Posted by: siberia37

Re: my first useful empeg program: Starter - 07/02/2002 10:22

Don't think this could be the case since the Starter program runs as a background process along with the player. You cannot tell it to start a program until after the player is running since it binds to hijack's menus. So are you saying the player unmounts /drive0 and mounts it as something else?? Also this still doesn't explain why I can't make a startup script with these contents:
cd /drive0/var/emptriv
emptriv&
and have it work when run from the serial console does it? Is there some other way to change working directory in linux besides "cd"??
Posted by: wfaulk

Re: my first useful empeg program: Starter - 07/02/2002 10:23

Sorry. I made an unreasonable assumption.

Edit: I took a look at your source, and I'm unsure about the reasons you're doing things the way you are. First, shell scripts should have their first line set to ``#!/bin/sh'' (or whatever shell you want to use), and should be set as executable. Second, it seems like a waste of resources to start bash via execve() in order for it to just execute other commands, unless you want to be able to execute commands like ``cd /drive0/var/emptris && ./emptris'', which would, in all honesty, probably solve your problem here.

My guess is that you're trying to execute startemptris by execve()ing ``/bin/sh -c startemptris''. First, the `-c' tells bash that the arg following is a shell command, instead of a script. Second, startemptris is probably not in bash's search path, so you'd need to specify a path to startemptris, even if it's just ``./startemptris''. Third, I'm guessing that startemptris isn't executable, so it'll still fail. My guess is that you should try to start the programs without necessarily executing bash to start them. Just run the programs directly and make sure that they're properly configured. That way, your program could run both shell scripts and binary executables, plus you avoid that useless overhead.

Also, you don't need to `&' empegVNC; it backgrounds itself, or at least the newer versions do.
Posted by: mlord

Re: my first useful empeg program: Starter - 07/02/2002 10:23

Actually, hijack is up and running long before the player, so you can bind to Hijack menus much earlier..
Posted by: siberia37

Re: my first useful empeg program: Starter - 07/02/2002 10:27

sure but the user couldn't select anything from the menu until after the player starts right? Therefore nothing will get executed by the starter until after the user selects "Start userlandapp" and /drive0 is mounted.
Posted by: mlord

Re: my first useful empeg program: Starter - 07/02/2002 10:29

Well, actually, you can select from the Hijack menu *anytime* after the hijack boot "splash" message, like while Tux is waving at you..
Posted by: siberia37

Re: my first useful empeg program: Starter - 07/02/2002 10:32

hmm did not know this, will have to try this sometime, always assumed player had to be running for hijack to come up.
Posted by: wfaulk

Re: my first useful empeg program: Starter - 07/02/2002 10:46

I edited the post that this is in reply to. Took longer than I thought (four more posts got added in the mean time), so I thought I'd draw your attention to it.
Posted by: Nosferatu

Re: my first useful empeg program: Starter - 07/02/2002 10:48

He Starter Works well for to start VNC server but i'd like to see how to stop it.

Maybe to see with wfaulk a command like empegVNC start | stop style and that stuff will be very cool !!!!!!!!
Posted by: siberia37

Re: my first useful empeg program: Starter - 07/02/2002 12:35

>Edit: I took a look at your source, and I'm unsure about the >reasons you're doing things the way you are. First, shell >scripts should have their first line set to ``#!/bin/sh'' (or >whatever shell you want to use), and should be set as >executable.
I took out the #!/bin/sh for testing since I couldn't get it to work, the script was marked executable.

> Second, it seems like a waste of resources to start bash >via execve() in order for it to just execute other commands, >unless you want to be able to execute commands like >``cd /drive0/var/emptris && ./emptris'', which would, in all >honesty, probably solve your problem here.

This is quite true I'm sure, I thought about executing the files directly, but then I ran into this problem with a program needing a working directory. And now I just realized my mistake with the startemptriv script I didn't run ./emptriv I just ran emptriv (doh!).

Ok the next version of Starter will run programs directly. If you need to run scripts (like in this case) you can just put /bin/sh -c /myscript in the program config file. I'll also have to look into a way of killing a program after it's started.

On a side note to the killing a program idea.. does anyone know how to Unbind a menu item in hijack?? This is what I need so starter could start a program, unbind it's menu item and then bind a new menu item called "Stop EmpegVNC" or whatever


Posted by: siberia37

Re: my first useful empeg program: Starter - 07/02/2002 12:36

I'll try to get stopping to work in the next version I make (which will hopefully be soon)..
Posted by: hybrid8

Re: my first useful empeg program: Starter - 17/03/2002 12:25

Any updates to your software recently?

Bruno
Posted by: siberia37

Re: my first useful empeg program: Starter - 18/03/2002 09:16

Never got the idea people were much interested in it.. if there's any interest I'd finish it up. I was also working on a userland app installer program for installing apps on the empeg for newbies who don't know how to use a bash prompt. It would basically allow userland app designers to make a script file which the installer program would run and do things like install files, set executable permissions and hopefully even add it to the startup scripts (or to Starters list). Any interest in something like this? I have the app installer halfway done if anyone thinks this would be useful.
Posted by: ellweber

Re: my first useful empeg program: Starter - 18/03/2002 09:43

Yes and Yes!!
Posted by: sancho

Re: my first useful empeg program: Starter - 18/03/2002 10:14

i, too, am interested in the app installer and starter...
--
sancho
Posted by: hybrid8

Re: my first useful empeg program: Starter - 18/03/2002 20:19

Since I popped this thread back to the top, YES from me as well. On both projects. The installer issue was just brought up in the empwake thread by Tony. He gave some good points on the stuff he'd really like to see supported.

Starter could be a really cool applet as well. It sounds perfect for launching apps you don't need launched when you first start the player. It will obviously be most useful as those apps start getting written and released... But it's good incentive.

Bruno
Posted by: tonyc

Re: my first useful empeg program: Starter - 18/03/2002 22:24

I'm interested in seeing what you've got so far with this installer... We could use something like that.
Posted by: siberia37

Re: my first useful empeg program: Starter - 19/03/2002 07:48

I'll try to get a functional release of the App installing program released in the next couple days. I think I'm done with the code that actually does the app installing, now I'm going to work on the code that interprets the script and gives the user choices on where to install the app, whether it should be run always at startup or only from Starter etc..

When I'm done with that part I'd like to go around and collect some userland apps from here and put them in one package with install scripts. If a user wanted to install any of the apps they would just have to double-click on the install script (ideally).
Posted by: tonyc

Re: my first useful empeg program: Starter - 19/03/2002 09:43

When I'm done with that part I'd like to go around and collect some userland apps from here and put them in one package with install scripts. If a user wanted to install any of the apps they would just have to double-click on the install script (ideally).

Sounds great. I'm all for anything that makes my stuff easier to install. I also think you'd want to allow for the script to ask the user questions, e.g. "where do you want to install this to?"

Mike Schrag mentioned some good ideas on a common format for these install packages, and he seems willing to integrate this functionality into jEmplode. Not sure if what you have will complement what he's doing or not, but it's worth looking at.
Posted by: siberia37

Re: my first useful empeg program: Starter - 19/03/2002 09:57

>Sounds great. I'm all for anything that makes my
>stuff easier to install. I also think you'd want to allow for >the script to ask the user questions, e.g. "where do you >want to install this to?"

It will definetly do this.. I plan on making a pretty wizard and everything and asking users if they want the app to start all the time, or only when they click "Start app" using Starter.

> Schrag mentioned some good ideas on a common format >for these install packages, and he seems willing to integrate >this functionality into jEmplode. Not sure if what you have >will complement what he's doing or not, but it's worth >looking at.

Ya.. looks like this would be a good job for Emplode. Oh well a little competition always helps improve products.
Posted by: tonyc

Re: my first useful empeg program: Starter - 19/03/2002 10:04

Agreed. In typical capitalist fashion, I will support whichever product does the job best, and when the other does it better, I will shamelessly switch allegiance in a heartbeat.
Posted by: mschrag

Re: my first useful empeg program: Starter - 19/03/2002 10:09

Let's definitely agree on the package formats, etc. so our apps can interoperate nicely ... Take a look at the App Installer thread that I spawned off of this one, and maybe we can get a discussion going about the right way to get this implemented.

Mike