From e091d94f910fd479ac0dc79c30712e074f5f169c Mon Sep 17 00:00:00 2001 From: brent s Date: Thu, 17 Jan 2019 05:45:17 -0500 Subject: [PATCH] oh gorram it. --- aif/scripts/post/sshsecure.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/aif/scripts/post/sshsecure.py b/aif/scripts/post/sshsecure.py index 1b4833e..4aa947d 100644 --- a/aif/scripts/post/sshsecure.py +++ b/aif/scripts/post/sshsecure.py @@ -338,14 +338,16 @@ def daemonMgr(): def main(): self_pidfile = '/tmp/sshsecure.pid' + is_running = False # First, check to see if we're already running. # This is where I'd put a psutil call... IF I HAD ONE. if os.path.isfile(self_pidfile): - is_running = subprocess.run(['pgrep', '-F', self_pidfile], stdout = subprocess.PIPE) - if is_running.stdout.decode('utf-8').strip() != '': - # We're still running. Exit gracefully. - print('We seem to still be running from a past execution; exiting') - exit(0) + is_running = subprocess.run(['pgrep', '-F', self_pidfile], stdout = subprocess.PIPE) + if is_running: + if is_running.stdout.decode('utf-8').strip() != '': + # We're still running. Exit gracefully. + print('We seem to still be running from a past execution; exiting') + exit(0) else: with open(self_pidfile, 'w') as f: f.write(str(os.getpid()))