# Hudson Slave

description "auto-upgrade-tester-jenkins-slave: distributed job control"
author "James Page <james.page@canonical.com>"

start on (local-filesystems and net-device-up IFACE!=lo)
stop on runlevel [!2345]

pre-start script
    . /etc/default/auto-upgrade-tester-jenkins-slave
    test -x /usr/bin/auto-upgrade-tester-jenkins-slave || { stop ; exit 0; }
    test -r /etc/default/auto-upgrade-tester-jenkins-slave || { stop ; exit 0; }
    test "${STARTUP}" = "true" || { stop; exit 0; }
end script

script
    . /etc/default/auto-upgrade-tester-jenkins-slave

    JDK_DIRS="/usr/lib/jvm/java-6-openjdk /usr/lib/jvm/java-6-sun"
    for jdir in $JDK_DIRS; do
        if [ -r "$jdir/bin/java" -a -z "${JAVA_HOME}" ]; then
            JAVA_HOME="$jdir"
        fi
    done
    export JAVA_HOME
    
    exec start-stop-daemon --start --chuid $USER:$GROUP --exec /usr/bin/auto-upgrade-tester-jenkins-slave -- $OPTS $HUDSON_MASTER 
end script
