From 379565816c27047915a56c89c2bf6699cc89ea46 Mon Sep 17 00:00:00 2001 From: Jafaruddin Lie <jafar.lie@monash.edu> Date: Wed, 6 Dec 2017 14:46:03 +1100 Subject: [PATCH] commit Former-commit-id: 7a126398d030d663e6ae48267cedd6fe25797ce4 --- roles/cleanup_x/files/cleanup-x.sh | 20 +++++++++++++++----- roles/cleanup_x/tasks/main.yml | 4 ++-- roles/gpu/tasks/main.yml | 1 + 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/roles/cleanup_x/files/cleanup-x.sh b/roles/cleanup_x/files/cleanup-x.sh index c909e0f2..fb65edfe 100755 --- a/roles/cleanup_x/files/cleanup-x.sh +++ b/roles/cleanup_x/files/cleanup-x.sh @@ -3,18 +3,28 @@ # Grep to find out whether there's X process running and user logged in # Is Desktop running on this machine? Anything greater than 0 means yes -DESKTOPRUNNING=`/opt/slurm-16.05.4/bin/squeue | grep desktop | grep -c $HOSTNAME` +SLURMCMD=`which sacct` + +if [ -n "$SLURMCMD" ] +then + SLURMCMD="$SLURMCMD -a --name=desktop --state=running --nodelist=$HOSTNAME --parsable --noheader | grep -c RUNNING" + +else + exit 1 +fi + +DESKTOPRUNNING=`eval "$SLURMCMD"` # Is X running? Anything greater than 0 means yes -XRUNNING=`ps aux | grep "/usr/bin/X" | grep -c root` +XRUNNING=`ps aux | grep "X :" | grep -c root` # This checks if no desktop is running but X is still there -if [ "$DESKTOPRUNNING" == 0 ] && [ "XRUNNING" > 0 ] +if [ "$DESKTOPRUNNING" == 0 ] && [ "$XRUNNING" > 0 ] then # Trying to get XPID - if [ -z "$XPID" ] + XPID=`ps -ef | grep "X :" | grep root | awk '{print $2}'` + if [ -n "$XPID" ] then - XPID=`ps -ef | grep "/usr/bin/X" | grep root | awk '{print $2}'` kill $XPID > /dev/null 2>&1 fi fi diff --git a/roles/cleanup_x/tasks/main.yml b/roles/cleanup_x/tasks/main.yml index 049720da..9a8e411b 100644 --- a/roles/cleanup_x/tasks/main.yml +++ b/roles/cleanup_x/tasks/main.yml @@ -1,7 +1,7 @@ --- - name: Copy cleanup-x.sh to the server - copy: - src: cleanup-x.sh + template: + src: cleanup-x.sh.j2 dest: /usr/local/bin/cleanup-x.sh mode: 0755 owner: root diff --git a/roles/gpu/tasks/main.yml b/roles/gpu/tasks/main.yml index 6a17e126..311f7c9a 100644 --- a/roles/gpu/tasks/main.yml +++ b/roles/gpu/tasks/main.yml @@ -151,6 +151,7 @@ - name: run nvidia-xconf-gen script: scripts/nvidia-xconf-gen.py register: nvidiacards + check_mode: no - name: set env for nvidia_card_lists set_fact: -- GitLab