diff options
author | Christophe Lyon <christophe.lyon@linaro.org> | 2019-03-06 20:48:37 +0000 |
---|---|---|
committer | Christophe Lyon <christophe.lyon@linaro.org> | 2019-03-06 20:48:37 +0000 |
commit | a7205ca33e25f8763fa6ccbc365ba9b370698da3 (patch) | |
tree | 1255046269e5aee063acdd7c6531d00ef7d387a6 | |
parent | 532a858fab12ed1e011c4a9e19461f19bf26f478 (diff) |
tcwg-cleanup-stale-containers.sh: Do not fail if there is no ssh-agent process to kill.
Handle two cases where killall can fail:
- command not found, in which case we want an error so that we know we have to install killall
- no ssh-agent process running, which is OK
Change-Id: I0d6d7e40eed6db7c6250f2231f05b8cca73c8355
-rwxr-xr-x | tcwg-cleanup-stale-containers.sh | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/tcwg-cleanup-stale-containers.sh b/tcwg-cleanup-stale-containers.sh index cc748c5c..df723dba 100755 --- a/tcwg-cleanup-stale-containers.sh +++ b/tcwg-cleanup-stale-containers.sh @@ -200,9 +200,24 @@ fi if [ "$cleanup_ssh_agent_hours" -gt "0" ]; then res=0; killall --older-than ${cleanup_ssh_agent_hours}h -u $USER ssh-agent & wait $! || res=$? + # Killall can fail for several reasons: + # return-code 127: command not found + # return-code 1: in general means no ssh-agent process was found + # In the first case, we want the cleanup job to fail, so that we + # know we need to install killall + # The second case is OK, unless killall fails for another + # reason. Assume OK for now. if [ $res != 0 ]; then - echo "WARNING: could not kill stale ssh-agent processes" - status=$(($status|16)) + case $res in + 127) + echo "WARNING: could not kill stale ssh-agent processes (killall command not found)" + echo "Increasing exit code to indicate killall is missing" + status=$(($status|16)) + ;; + 1) + echo "WARNING: could not kill stale ssh-agent processes" + ;; + esac fi fi |