X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=utils%2Fjenkins-jnlp-connect.sh;h=00c19971f279116afbdbf1b1ab49fe1166a91c7e;hb=9e047cf55938abb786575f7d43ca150693713684;hp=d048859c27db9e88e13c9ab1e78d225077455dea;hpb=fb6e5333dec7223bc4aa397e0930a0e4eb48662e;p=releng.git diff --git a/utils/jenkins-jnlp-connect.sh b/utils/jenkins-jnlp-connect.sh index d048859c2..00c19971f 100755 --- a/utils/jenkins-jnlp-connect.sh +++ b/utils/jenkins-jnlp-connect.sh @@ -78,7 +78,7 @@ makemonit () { echo "Writing the following as monit config:" cat << EOF | tee $monitconfdir/jenkins check process jenkins with pidfile /var/run/$jenkinsuser/jenkins_jnlp_pid -start program = "/bin/bash -c 'cd $dir; export started_monit=true; $0 $@'" as uid "$jenkinsuser" and gid "$jenkinsuser" +start program = "/usr/bin/sudo -u $jenkinsuser /bin/bash -c 'cd $dir; export started_monit=true; $0 $@'" stop program = "/bin/bash -c '/bin/kill \$(/bin/cat /var/run/$jenkinsuser/jenkins_jnlp_pid)'" EOF } @@ -87,7 +87,7 @@ if [[ -f $monitconfdir/jenkins ]]; then #test for diff if [[ "$(diff $monitconfdir/jenkins <(echo "\ check process jenkins with pidfile /var/run/$jenkinsuser/jenkins_jnlp_pid -start program = \"/bin/bash -c 'cd $dir; export started_monit=true; $0 $@'\" as uid \"$jenkinsuser\" and gid \"$jenkinsuser\" +start program = \"usr/bin/sudo -u $jenkinsuser /bin/bash -c 'cd $dir; export started_monit=true; $0 $@'\" stop program = \" /bin/bash -c '/bin/kill \$(/bin/cat /var/run/$jenkinsuser/jenkins_jnlp_pid)'\"\ ") )" ]]; then echo "Updating monit config..." @@ -100,6 +100,7 @@ fi if [[ $started_monit == "true" ]]; then wget --timestamping https://build.opnfv.org/ci/jnlpJars/slave.jar && true +chown $jenkinsuser:$jenkinsuser slave.jar if [[ -f /var/run/$jenkinsuser/jenkins_jnlp_pid ]]; then echo "pid file found" @@ -113,9 +114,12 @@ then echo "pid file found" fi fi -exec $connectionstring & -echo $! > /var/run/$jenkinsuser/jenkins_jnlp_pid -#trap 'rm -f "$pidfile"; exit' EXIT SIGQUIT SIGINT SIGSTOP SIGTERM +if [[ run_in_foreground == true ]]; then + $connectionstring +else + exec $connectionstring & + echo $! > /var/run/$jenkinsuser/jenkins_jnlp_pid +fi else echo "you are ready to start monit" @@ -165,7 +169,8 @@ do s ) slave_secret="$OPTARG";; h ) usage; exit;; t ) started_monit=true - skip_monit=true ;; + skip_monit=true + run_in_foreground=true ;; f ) test_firewall ;; \? ) echo "Unknown option: -$OPTARG" >&2; exit 1;; esac