From ad08eb4f83a5ac7edbbd84ce7e9e574b74841d6b Mon Sep 17 00:00:00 2001 From: Christian Flamm Date: Fri, 13 Jul 2018 10:15:21 +0200 Subject: [PATCH] allow to interrupt token renewal --- afpre | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/afpre b/afpre index e501917..7c94dd0 100755 --- a/afpre +++ b/afpre @@ -182,7 +182,13 @@ awsenv() { env | grep -i --color=never ^aws } +ctrl_c () { + echo " Interrupted by user..." +} + renew() { + trap ctrl_c INT + echo authenticating as ${NAME} for ${ACCOUNT}/${ROLE} against ${HOST} JSON=\$(basic_auth https://${HOST}${_PATH}/${ACCOUNT}/${ROLE} ${X1XBN02R}) || error_msg "... failed!" export AWS_ACCESS_KEY_ID=\$(json_value "\${JSON}" AccessKeyId) @@ -191,6 +197,8 @@ renew() { export AWS_SECURITY_TOKEN=\$(json_value "\${JSON}" Token) export AWS_VALID_SECONDS=\$((\$(secs_since_epoch \$(json_value "\${JSON}" Expiration))-\$(date +%s))) SECONDS=0 + + trap - INT } condrenew() {