Boot straight to Java app

Home Forums General Boot straight to Java app

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2938
    Terry Gooding
    Participant

    I’ve managed to successfully write a Java app using the Multitech SDK on MT100EOCG-H5.

    This application will need to start automatically once Linux has booted as it will be part of an isolated system.

    Googling this has thrown up various ways but was wondering what Multitech would recommend?

    Also – does your Linux distribuition support more than one user as the useradd command says command not found.

    Thanks

    #4550

    Terry,

    Below find a good way to start the application on boot:

    Writing the Startup Script

    Having an application launch automatically on power-up is quite simple on the OCG. The easiest way to do this is first to write a Linux shell script that when executed launches all of the applications you want. A shell script can be created through making a new text file with extension “.sh”. At the top of this file include #! /bin/sh which signifies this as a shell script. Within the shell script add the command line components you want to run as you would in any shell script.

    The shell script that you make should, by standard Linux convention, be placed in the /etc/init.d directory. This is where a lot of the important startup scripts and configurations are stored. After the file has been written test it out directly and make sure that all of the permissions on your directories are set appropriately. For more information on writing a shell script refer to one of the hundreds of references on the Internet.

    Running the Script

    In order for this script to run you must add this file to one of a few special directories that have scripts which are automatically executed on power-up. For custom built applications we recommend having your script be run from the /etc/rc5.d directory. Since we want the ability to enable or disable this script from starting on power-up without having to remove it entirely, we will use a symbolic link. You can think of this symbolic link as a file descriptor in the rc5.d directory that points to the script that we made in init.d. Having this symbolic link allows us to temporarily remove the link at some later time to stop the script from running while leaving the actual script it in the init.d folder so it can be enabled again in the future.

    An important thing to note is that the name of the symbolic link you place in rc5.d must have a particular format. Since we are starting programs it must begin with the letter S followed by a number between 0 and 99, which determines when the script is supposed to run. It is also important that this number is not already used within the rc5.d folder. Typically we want our application to run as close to last as possible, but 99 is already taken in the standard build. We therefore recommend that your symbolic link start with S98. As an example, to create a symbolic link for a startup script called AppStart.sh use the following command:

    ln -s /etc/init.d/AppStart.sh /etc/rc5.d/S98AppStart

    After making the link you can try running it just like you would any shell script. After validating the symbolic link is good, the last thing to do is to try it out by simply rebooting the device. When the device comes back on your script should have run and any applications associated with it. For additional help refer to one of many articles about the Linux boot process on the Internet.

    Hope that helps!

    – Jonathan

    #4551
    Bryan Tran
    Moderator

    Hi Terry,


    Also – does your Linux distribuition support more than one user as the useradd command says command not found.


    *Try: adduser command.

    Regards,

    BT

    #4552
    Terry Gooding
    Participant

    Jonathan, Bryan

    Thanks for the info – solved both my problems.

    For anyone interested there’s quite a good description of whats going on here.

    http://www.linux.com/news/enterprise/systems-management/8116-an-introduction-to-services-runlevels-and-rcd-scripts

    Terry

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.