Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Solved] somewhat specialized X application
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
RioFL
Guru
Guru


Joined: 31 Oct 2002
Posts: 407

PostPosted: Thu Nov 08, 2007 1:32 am    Post subject: [Solved] somewhat specialized X application Reply with quote

I have a need to do the following and since I have never configured X beyond what is needed to load kde using kdm I am quite lost in the sea of configurations.

Here is what I need to do:

1. the X server must run on boot executing a specific application as a specific user which will never be taken down until system shutdown.

2. no one will ever access locally as there is no local monitor/kybd/mouse connected. it will be accessed remotely via passworded vnc and we need to be taken directly into the already running application and not disturb anything on exit. i believe there are some options for vnc which will do this. security will be handled by passworded vnc, border router ACL permitting only 2 static ip addresses to access this port (probably more than 1 to allow choice of resolution) on this specific machine, and also iptables on this machine to do the same thing.

3.X alone is sufficient, we do not need a window manager like kde or gnome unless required to do what we want.

I am at a loss what files to configure to do this autostarting of an X application as a specific user. it cannot be root. I can configure vnc to give me a remote display so that is not an issue. My problem deals specifically with starting X and running this app as some user automatically with no manual logins as no one will ever be able to provide that. This part must be 'human free'. We both need to be able to view simultaneously (from remote) the data this app displays.

We are running xorg-x11 v 7.2.

Any ideas? Am I asking the impossible?


Last edited by RioFL on Fri Nov 09, 2007 1:55 pm; edited 1 time in total
Back to top
View user's profile Send private message
flybynite
l33t
l33t


Joined: 06 Dec 2002
Posts: 620

PostPosted: Thu Nov 08, 2007 3:54 am    Post subject: Re: somewhat specialized X application Reply with quote

RioFL wrote:

Any ideas? Am I asking the impossible?


No, actually it's easy. So easy that it's hard to find :-) and there are many ways of actually doing this.

Always backup original files.

/etc/conf.d/local.start is run on boot. Add something like this:
Code:

su USER -c 'source /etc/profile;startx'

to autostart X as user USER.

X looks for and runs ~/.xinitrc so add your program to that file on a line by itself. Nothing else is required. No window managers, kde gnome, blackbox etc, just plain X.


~/.xinitrc
Code:

programtostart



Thats it. If your program tends to crash or can be accidently exited then you can use inittab with the .xinitrc above instead of the local.start trick.

Comment (#) the original line c6 and add
Code:

c6:2345:respawn:/usr/bin/openvt -fwc 2 -- /bin/su - USER -c /usr/bin/startx
Back to top
View user's profile Send private message
i92guboj
Bodhisattva
Bodhisattva


Joined: 30 Nov 2004
Posts: 10315
Location: Córdoba (Spain)

PostPosted: Thu Nov 08, 2007 5:46 am    Post subject: Re: somewhat specialized X application Reply with quote

flybynite wrote:
RioFL wrote:

Any ideas? Am I asking the impossible?


No, actually it's easy. So easy that it's hard to find :-) and there are many ways of actually doing this.

Always backup original files.

/etc/conf.d/local.start is run on boot. Add something like this:
Code:

su USER -c 'source /etc/profile;startx'

to autostart X as user USER.
[/code]


I haven't tested this, and it is certainly a bit scary that way. I don't know if this will work, because I don't really know how gentoo treats the services at bootup. But I think you should add an ampersand at the end of that command, unless you wanna your local.start script to be locked until X is closed. Otherwise, if any service is to be run after the "local" service, it will never be run, and you can run into trouble.

I would instead just use mingetty to autologin (google, it's easy to find).

Once you auto-login, you can use the bash initialization files (in this case, ~/.bash_profile, since it is a login shell) to set any vars you want, initialize additional stuff, and finally launch X. You will still need to put the X stuff into .xinitrc, as said above.

About the crash thingie, the easier, the better, just put it all into .xinitrc

Code:

while true
do
    <progname>
done


That way, X will not go down in first place. Only the application will be restarted, much like the same way you restart or --replace a window manager.
Back to top
View user's profile Send private message
flybynite
l33t
l33t


Joined: 06 Dec 2002
Posts: 620

PostPosted: Thu Nov 08, 2007 7:56 am    Post subject: Reply with quote

I'm not the sole author of that tip so I can only say it works and many people use it to start mythtv. It may be that adding the & at the end of su USER -c 'source /etc/profile;startx &' is more correct, but does work fine as is.

The inittab is done on purpose. It is used with highly available programs because it is desirable to restart X when the main X program crashes/restarts to ensure system stability.

RioFL described the program as the sole user of X and no one is locally logged in, so the box may be considered as a remote server. The precaution of restarting X ensures the main program will alway come back up even in case of an X crash or X program crash that leaves X in an unknown state.


Like I said, there are many ways to do this!!
Back to top
View user's profile Send private message
RioFL
Guru
Guru


Joined: 31 Oct 2002
Posts: 407

PostPosted: Thu Nov 08, 2007 12:02 pm    Post subject: Reply with quote

Thank you both very much!!

Jeeze, now I feel like an idiot. :) It's so easy! I was looking so deeply I completely missed this. The way the things are spread around it really is not completely obvious, but... I will work on this today and see what happens...

Again Thanks!
Back to top
View user's profile Send private message
i92guboj
Bodhisattva
Bodhisattva


Joined: 30 Nov 2004
Posts: 10315
Location: Córdoba (Spain)

PostPosted: Thu Nov 08, 2007 2:02 pm    Post subject: Reply with quote

flybynite wrote:
I'm not the sole author of that tip so I can only say it works and many people use it to start mythtv. It may be that adding the & at the end of su USER -c 'source /etc/profile;startx &' is more correct, but does work fine as is.


Yep, but unless I am missing something, any service that is to be started after "local" will never be started, I think. I haven't tested it, though. "local" always tends to be started the latest, but that is not carved in stone, and some weird stuff can happen. Maybe it will not affect you if you use parallel bootup or some other ugly trick.

And yes, there are lots os ways to do this same thing, isn't linux wonderful? :)
Back to top
View user's profile Send private message
RioFL
Guru
Guru


Joined: 31 Oct 2002
Posts: 407

PostPosted: Thu Nov 08, 2007 5:14 pm    Post subject: Reply with quote

i92guboj wrote:
flybynite wrote:
I'm not the sole author of that tip so I can only say it works and many people use it to start mythtv. It may be that adding the & at the end of su USER -c 'source /etc/profile;startx &' is more correct, but does work fine as is.


Yep, but unless I am missing something, any service that is to be started after "local" will never be started, I think. I haven't tested it, though. "local" always tends to be started the latest, but that is not carved in stone, and some weird stuff can happen. Maybe it will not affect you if you use parallel bootup or some other ugly trick.

And yes, there are lots os ways to do this same thing, isn't linux wonderful? :)


hehe yeah it is. By default local is the very last thing to run before receiving the login prompt so unless something is haywire nothing can be loaded after local until logged in. Unless someone messes with the system boot scripts to add something after local. :)
Back to top
View user's profile Send private message
i92guboj
Bodhisattva
Bodhisattva


Joined: 30 Nov 2004
Posts: 10315
Location: Córdoba (Spain)

PostPosted: Thu Nov 08, 2007 6:30 pm    Post subject: Reply with quote

RioFL wrote:
i92guboj wrote:
flybynite wrote:
I'm not the sole author of that tip so I can only say it works and many people use it to start mythtv. It may be that adding the & at the end of su USER -c 'source /etc/profile;startx &' is more correct, but does work fine as is.


Yep, but unless I am missing something, any service that is to be started after "local" will never be started, I think. I haven't tested it, though. "local" always tends to be started the latest, but that is not carved in stone, and some weird stuff can happen. Maybe it will not affect you if you use parallel bootup or some other ugly trick.

And yes, there are lots os ways to do this same thing, isn't linux wonderful? :)


hehe yeah it is. By default local is the very last thing to run before receiving the login prompt so unless something is haywire nothing can be loaded after local until logged in. Unless someone messes with the system boot scripts to add something after local. :)


Still, it is better to just add &.

Otherwise, the offending process will remain in the background. Not that it will harm the performance or waste too much resources. But there is no reason why it should be there. One less process in the background, and everyone is happy.
Back to top
View user's profile Send private message
RioFL
Guru
Guru


Joined: 31 Oct 2002
Posts: 407

PostPosted: Thu Nov 08, 2007 6:41 pm    Post subject: Reply with quote

i92guboj wrote:
RioFL wrote:
i92guboj wrote:
flybynite wrote:
I'm not the sole author of that tip so I can only say it works and many people use it to start mythtv. It may be that adding the & at the end of su USER -c 'source /etc/profile;startx &' is more correct, but does work fine as is.


Yep, but unless I am missing something, any service that is to be started after "local" will never be started, I think. I haven't tested it, though. "local" always tends to be started the latest, but that is not carved in stone, and some weird stuff can happen. Maybe it will not affect you if you use parallel bootup or some other ugly trick.

And yes, there are lots os ways to do this same thing, isn't linux wonderful? :)


hehe yeah it is. By default local is the very last thing to run before receiving the login prompt so unless something is haywire nothing can be loaded after local until logged in. Unless someone messes with the system boot scripts to add something after local. :)


Still, it is better to just add &.

Otherwise, the offending process will remain in the background. Not that it will harm the performance or waste too much resources. But there is no reason why it should be there. One less process in the background, and everyone is happy.


very true. both ways appear to work initially, however i am having trouble keeping X in memory when running mingetty. it seems it executes, does everything i have in .xinitrc then exits... i have a test twm & and a clock line & and below that i just create a test file to see that it executed.. by the time i log in via ssh after reboot, X has vanished from the process list with no errors that i can find in any log and a ps shows tty1 missing. my inittab line is:

Code:
c1:12345:respawn:/sbin/mingetty --noclear --autologin <username> tty1


ideas?
Back to top
View user's profile Send private message
i92guboj
Bodhisattva
Bodhisattva


Joined: 30 Nov 2004
Posts: 10315
Location: Córdoba (Spain)

PostPosted: Thu Nov 08, 2007 7:50 pm    Post subject: Reply with quote

Can you post your whole .xinitrc?

In xinitrc you need to have the last line without '&', because that script needs to lock X. For that same reason, you can't use as a locker a program that automatically forks to the background. Any program would do. It can be your program, or it can be even a simple "xclock" (agan, no &) as the last line.

If you close the locker, X will be closed. If there is no locker, X will be closed as well.
Back to top
View user's profile Send private message
RioFL
Guru
Guru


Joined: 31 Oct 2002
Posts: 407

PostPosted: Thu Nov 08, 2007 11:13 pm    Post subject: Reply with quote

i92guboj wrote:
Can you post your whole .xinitrc?

In xinitrc you need to have the last line without '&', because that script needs to lock X. For that same reason, you can't use as a locker a program that automatically forks to the background. Any program would do. It can be your program, or it can be even a simple "xclock" (agan, no &) as the last line.

If you close the locker, X will be closed. If there is no locker, X will be closed as well.


That explains it then!

Code:
cat .xinitrc
twm &
xclock -geometry 50x50-1+1 &
ps ax>/home/<username>/test.txt
xterm -geometry 80x20+494-0 &


I'll try pulling the & out of the last line
Back to top
View user's profile Send private message
RioFL
Guru
Guru


Joined: 31 Oct 2002
Posts: 407

PostPosted: Thu Nov 08, 2007 11:43 pm    Post subject: Reply with quote

RioFL wrote:
i92guboj wrote:
Can you post your whole .xinitrc?

In xinitrc you need to have the last line without '&', because that script needs to lock X. For that same reason, you can't use as a locker a program that automatically forks to the background. Any program would do. It can be your program, or it can be even a simple "xclock" (agan, no &) as the last line.

If you close the locker, X will be closed. If there is no locker, X will be closed as well.


That explains it then!

Code:
cat .xinitrc
twm &
xclock -geometry 50x50-1+1 &
ps ax>/home/<username>/test.txt
xterm -geometry 80x20+494-0 &


I'll try pulling the & out of the last line


That worked! X stayed running. Thanks!
Back to top
View user's profile Send private message
RioFL
Guru
Guru


Joined: 31 Oct 2002
Posts: 407

PostPosted: Fri Nov 09, 2007 1:53 pm    Post subject: Reply with quote

Although X is behaving perfectly as I want, I now find several more hurdles that I do not have when using kdm.
For some reason, X will not give me the apps remotely, all I get is the grey screen. After trying all the suggestions
I found in these forums and on other places, I am temporarily giving up due to deadline constraints and will use autologin via kdm into kde
and use the kde shared desktop method to get remote viewing of the application.

I will set up a test bed to keep working on this because an 'appliance' such as this would be very useful in our organization.

Thanks for all your help!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum