How to automatically launch applications on system's startup

Q: How can I automatically run an application on system's startup?

A: It's possible to run one or more programs at system startup modifying the file /root/.xinitrc as follows: insert each command line before the last command line "gpe-confd". We suggest to create in the folder /root/ a shell script (file with .sh extension) containing all the user's applications command lines, and then call that script execution before the gpe-confd command. Please note that the script will must be launched in background mode, otherwise the normal startup of the gpe-confd program (that manages the graphic interface of the mobile device) will not be reached until the script will end: in order to launch a command or a script in background mode, the administrator will have to add the character & after the script's name or after the command to launch.

Example:
Suppose that the original /root/.xinitrc file contains the following instructions:

#! /bin/sh
/sbin/scanwedge
#x11vnc &
cp /root/.matchbox/mbdock.session.default /root/.matchbox/mbdock.session
matchbox-session &
gpe-confd

If the administrator would run some programs using a script called "myApp.sh" and saved in the folder /root/, he should modify the content of the file as follows:

#! /bin/sh
/sbin/scanwedge
#x11vnc &
cp /root/.matchbox/mbdock.session.default /root/.matchbox/mbdock.session
matchbox-session &
#user application's startup:
/root/myApp.sh &
gpe-confd

The /root/myApp.sh script will contains an executable instruction or a command line. For example, if the administrator would run the standard software Highway-g Inventario, he should place in the script the following instructions (taken from the application's startup link):

#! /bin/sh
cd /usr/hwg-inv/
/usr/share/pmea-fp/bin/cvm -Xbootclasspath/a:jdbc.jar:RXTXcomm.jar -cp absfmk.jar:swt.jar:derby.jar:HWgInv.jar:. -Dsun.boot.library.path=/usr/share/pmea-fp/ -Djava.library.path=/usr/share/pmea-fp/ start.Inventario /usr/hwg-inv/
 

NOTES:

  • the standard convention for shell scripts impose to start each script file with the following line:

#! /bin/sh

  • each script file or program that will be launched must have executions privileges: it is possible to manage and change files permissions using the chmod command from console or, more easily, changing file's properties with WinSCP or an other SSH client from the pc connected to the mobile device.