"/etc/init.d/hudson start" fails to write Hudsons PID to /var/run/hudson.pid. As result "/etc/init.d/hudson stop" wont work.
When starting Hudson the script compares its own Session PID (variable $MY_SESSION_ID) to that of all processes running under user hudson with matching command line (variable $sess). However the value in $MY_SESSION_ID begins with a leading blank, while $sess contains numbers only - the comparison fails.
Also "/etc/init.d/hudson restart" will not start a new process if the "start" command is run too soon after "stop". I've added a five seconds break between the commands.
Please see attached patch.