LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   Automatically start graphical (SDL) program as root on non-graphical Debian (https://www.linuxquestions.org/questions/debian-26/automatically-start-graphical-sdl-program-as-root-on-non-graphical-debian-708759/)

the_merovingian 03-03-2009 12:33 AM

Automatically start graphical (SDL) program as root on non-graphical Debian
 
I'm not a Linux noob, but I am far from guru. I'm running a single board computer with a slightly customized Debian Etch (customized by the SBC vendor). No Gnome/KDE/X installed.

My application is a control application which uses SDL (Simple DirectMedia Layer) to paint some basic graphics on the VGA. I need to run it as root because the application calls iopl() to access an IO port.

If I run my application manually from the command line, life is sweet. From Googling around, I found http://www.debian-administration.org/articles/28, and hence I:

1) Created a script in /etc/init.d
2) Executed "update-rc.d scriptName defaults" to link the script into the boot sequence

All very straightforward. My application starts at boot. But when I try to SSH/SFTP into the SBC, I get "Connection refused". So I can't manage the SBC anymore, and this is a big problem. I am not sure if it's relevant, but my application starts before the SSH daemon.

My script looked like:

case "$1" in
start)
echo "Starting my application"
cd /home/user
./MyApplication
;;


It occured to me that the problem might be that my application is starting in the foreground. So I added an "$" to that line. Now I can SSH/SFTP into the SBC again, but I have a blank screen instead of my SDL graphics. This is possibly not surpising now that my application is running in the background.

How do I get the best of both worlds?

makuyl 03-03-2009 03:20 PM

Make it start after ssh looks like the easiest way.
If your default runlevel is 2 (check with "grep default /etc/inittab"), do a "ls -l /etc/rc2.d|grep ssh" to see which startup number it has.
Say it had 20, do "update-rc.d scriptName start 25 2 . stop 25 0 1 6 ."
Or you can use sysv-rc-conf to do it.


All times are GMT -5. The time now is 01:33 PM.