diff --git a/utils/repo-lock.sh b/utils/repo-lock.sh new file mode 100755 index 0000000..7829c01 --- /dev/null +++ b/utils/repo-lock.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +function req { + ssh c4science-db01 "mysql -B -e \"$@\"" 2> /dev/null +} + +repo=$(req 'select FROM_UNIXTIME(r.epoch), r.syncWait, r.repositoryPHID, a.name from repository_syncevent as r, phabricator_almanac.almanac_device as a where r.properties like "%lock%" and r.devicePHID=a.phid group by r.repositoryPHID,a.name order by epoch desc limit 10;;' | tail -n +2) +if [ -z "$repo" ]; then echo "Nothing to do.. exiting"; exit; fi + +while read -r r; do + TS=$(echo "$r" | cut -f1 | jq -r '.epoch') + if [ $TS -lt $(($(date +%s)-300)) ]; then # older than 5 minutes + echo "$r" | cut -f2,3 + fi +done <<< "$repo" +