Update dashboard
[releng.git] / utils / jenkins-jnlp-connect.sh
index 03e47b8..00c1997 100755 (executable)
@@ -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,7 +100,7 @@ fi
 
 if [[ $started_monit == "true" ]]; then
 wget --timestamping https://build.opnfv.org/ci/jnlpJars/slave.jar && true
-chown $jenkinsuser $jenkinsuser slave.jar
+chown $jenkinsuser:$jenkinsuser slave.jar
 
 if [[ -f /var/run/$jenkinsuser/jenkins_jnlp_pid ]];
 then echo "pid file found"
@@ -169,7 +169,7 @@ 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;;