For some reason my if condition for a file and a directory not existing is not processing correctly. The script thinks that the file and directory exist when they do not.
#!/usr/bin/bash
lockdir=/opt/someOtherDis/qa_test_lock
puppetlock=/var/opt/puppetLockDirs/agent_catalog_run.lock
if [ ! -f "$puppetlock" ] && [ ! -d "$lockdir"]; then
#Get a url and grep it to get stuff
else
su -c "echo ls puppetlock results: $(ls -lrt $puppetlock) and qa lock results: $(ls -lrt $lockdir) >> /var/log/dirStuff/test-qa-run.log" -m "someUser"
su -c "echo $(date +\"%m-%d-%T\") Puppet or QA tests are running. Did not attempt to update artifact version. >> /var/log/dirStuff/test-qa-run.log" -m "someUser"
fi
I added the output of the ls to make sure I can see if puppet or the qa lock exists.
Here is the output of the log file, first check was when I run puppet manually so I could make sure things worked.
02-09-08:16:01 Puppet or QA tests are running. Did not attempt to update artifact version. ls puppetlock results: -rw-r--r-- 1 root root 5 Feb 9 08:27 /var/opt/lib/pe-puppet/state/agent_catalog_run.lock and qa lock results:
02-09-08:28:01 Puppet or QA tests are running. Did not attempt to update artifact version.
02-09-08:30:02 app_versions.json has not been modified in the last 30 minutes ls puppetlock results: and qa lock results:
02-09-08:30:02 Puppet or QA tests are running. Did not attempt to update artifact version. ls puppetlock results: and qa lock results:
02-09-08:32:01 Puppet or QA tests are running. Did not attempt to update artifact version.
"$lockdir"and], no?