Save the text below on /etc/init.d/hudson
Change the value of these variables to match your settings:
HUDSON_HOME=/home/html/discovery/hudson/root
DAEMON="$HUDSON_HOME/../jre1.6.0_12/bin/java"
DAEMON_ARGS="-jar "$HUDSON_HOME/hudson.war" --httpPort=-1 --ajp13Port=8102 --ajp13ListenAddress=127.0.0.1 --prefix=/hudson"
Hudson will be started has www-data user.
The HUDSON_HOME directory should be set to user www-data and group www-data.
Shell script