st-approve-all rewrite

- drop using parallel;
- explicitly use SSH control socket.
This commit is contained in:
Ivan A. Melnikov 2024-06-24 16:50:36 +04:00
parent 10ceed69fe
commit ecc3af193a

View File

@ -12,16 +12,41 @@ if [ -z "$*" ]; then
exit 0
fi
mkdir -p ~/.ssh/control
CONTROL_A="-oControlPath=~/.ssh/control/st-approve-all-a-%r-%h-%p"
CONTROL_R="-oControlPath=~/.ssh/control/st-approve-all-r-%r-%h-%p"
cleanup () {
echo "cleaning up..."
ssh -O exit "$CONTROL_A" -N $alias ||:
ssh -O exit "$CONTROL_R" -N $robot_alias ||:
}
trap cleanup EXIT
ssh -oControlMaster=yes "$CONTROL_A" -N "$alias" &
ssh -oControlMaster=yes "$CONTROL_R" -N "$robot_alias" &
echo "This will approve the following tasks:"
echo
parallel -k ssh "$alias" task show --brief {} ::: "$@"
for task_id; do
ssh "$CONTROL_A" "$alias" task show --brief "$task_id"
done
echo -n "Will start approving in 5 seconds. Last chance to abort..."
sleep 5
echo " LOST."
read -p "Shouid I go ahead (y/N)> " choice
case "$choice" in
y|Y ) ;;
* ) exit 1;;
esac
parallel --retry-failed ssh "$alias" task approve {} all ::: "$@"
parallel --retry-failed --retries 3 -k ssh "$robot_alias" task run --commit --unhurry {} ::: "$@"
for task_id; do
echo 'approved' | ssh "$CONTROL_A" "$alias" task approve "$task_id" all
done
for task_id; do
ssh "$CONTROL_R" "$robot_alias" task run --commit --unhurry -m sync_with_sisyphus "$task_id"
done
echo "DONE."