Shell script for service

Hi,

I want to add an application as a service in Linux(Fedora 12). It should be run always for monitoring my system. It never terminate unless kill it. I wrote this script, put it on /etc/init.d/myapp and added it to run level 2345:

#!/bin/bash
#
# chkconfig: 2345 20 80
# description: myapplication
#
# Get function from functions library
. /etc/init.d/functions
# Start myapp
start() {
        initlog -c "echo -n Starting myapp: "
         ./home/myuser/myapp -i eth0
        ### Create the lock file ###
        touch /var/lock/subsys/myapp
        success $"myapp startup"
        echo
}
# Stop myapp
stop() {
        initlog -c "echo -n Stopping myapp: "
        killproc myapp
        ### Now, delete the lock file ###
        rm -f /var/lock/subsys/myapp
}
### main logic ###
case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        status)
                status myapp
                ;;
        restart)
                stop
                sleep 5s
                start
                ;;
        *)
                echo $"Usage: $0 {start|stop|restart}"
                exit 1
esac

exit 0

At now, when i start it, it was started. BUT after rebooting, system isn't boot and stopped after starting myapp(because of script can not reach end of itself and it is stopped in line#11).

Please help me.

NOTE:
I need help in writing script. I don't need help for booting my system.

You probably need to put Start- and Kill-scripts in the respective rc.d-directories for the runlevels (/etc/rcX.d/, where X is the runlevel). There is a special tool to accomplish this: chkconfig. Install the package "chkconfig-1.3.45-1" and read the man page for chkconfig.

I hope this helps.

bakunin

Already i added myapp to services by chkconfig.

chkconfig --add myapp
chkconfig --level 2345 myapp on

Problem is:
When system is booting, after starting myapp script there is in /etc/init.d/myapp, when the myapp script reach line#11, it start myapp. Because myapp never terminate, the script doesn't reach end of itself. So booting my system doesn't continue and wait until myapp terminate.

Only needs running the process in background:

./home/myuser/myapp -i eth0 &