maandag 15 april 2013

Startup script for Ubuntu


When you need to start a service (like Glassfish or Play) in Ubuntu, you can take this script as a template:


#! /bin/sh
case "$1" in
    start)
 ... execute a shell script here ...
        ;;
    stop)
       ... execute a shell script here ...
        ;;
    restart)
       ... execute a shell script here ...
        ;;
esac
exit 0

Make sure to make your scripts executable. In order to get it running during startup, add a link to the init.d directory and register the service-script to make it run as first service (depends on your system which priority you assign, take care here, I just took 01 as an example) 

cd /etc/init.d
sudo ln -sf  ~/your-script.sh your-script.sh
sudo update-rc.d your-script.sh defaults 01 01

Reboot and you'll see that your services get started.

Geen opmerkingen:

Een reactie posten