Hi
I have a custom power pc board which runs linux and would like to auto start an application at boot up. I found several references such as **broken link removed** and https://askubuntu.com/questions/9853/how-can-i-make-rc-local-run-on-startup. Please clarify which one to follow? The distro in the board is 2.6.34
I found another link **broken link removed**, which says slightly differently than the first one. Are there different ways to make it work? and what additional details do i have to provide?
The 'systemd' method can start your program as a service. It is basically a small text file containing a link to your application and a list of dependencies so it can work out whether all the necessary support programs are running and if not, start them. It is probably better suited to programs you want to run in the background rather than ones interacting directly with the user but it can do both.
'rc.local' as c_mitra explained is just a script that runs after a user is logged in. It is just plain text and contains exactly what you would type at a command prompt achieve the same thing. 'rc.local' lives in '/etc' so to edit it you may need root privileges, for example you might need to use 'sudo nano /etc/rc.local' if nano is the text editor you want to use.
Since I use powerpc which does not have hard-disk, all I have to do is to rebuild rootfs and do suitable modifications in rc.local as you suggested. Now for the steps, please confirm if the following procedure is valid
1. I place my application (say hello) in /usr/bin directory
2. I edit rc.local and add line hello &
3. rebuild rootfs and fuse it into my target
4. after rebooting, application should auto start
Hi mitra
please excuse me. I am reconfirming this because in several links, they talk about permissions to execute the application, create symlink and so on. So I want to absolutely sure that the method indicated in #7 will actually work. Otherwise my experiment will be iterative one trying to figure out the right method
I usually put all startup routines at the crontab, adding the @reboot prefix, but this file should not be manually eddited, but called from the command line with the sufix -e. It is worthy to be aware that sometimes it is needed to add the sufix sudo before the program/script that is being called there.
It runs when you execute the program from command line, right? Just to confirm, run it as root and verify (sudo su) that it is going to run as root also. If in doubt, change permissions for all (a+x) so that anyone can run it.
But I admit that I have never build rootfs for another target.
The proposed method mentioned in #6 actually works like a charm. Now I would like to exit this infinite loop and come back to login prompt. Is there any way to do it?
You need to use keypress as a check in the routine. If any key is pressed then exit the routine. Else you can use Ctrl-C to terminate the program. You can also trap Ctrl-C and do something else.
Thanks and one last final question. I have to mknode and insmod custom drivers in rc.local. Any proven method? custom drivers are kernel module. Where should I store them and how do i invoke them in rc.local?
The usual place is under /lib/modules/ and you will find lots of directories there. Put it in the most appropriate place. It is supposed to look up the right one...
Loading the driver is the first of a series of steps before you can use the driver well. But that depends on the exact nature of the device (assuming it is a device driver).
From the I/O point, all device drivers are files: either character or block based. Writing a driver is easy; but writing a driver that works well is going to cost you many nights.