Skip to content

Commit

Permalink
allow to interrupt token renewal
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Flamm committed Jul 13, 2018
1 parent 925ebf2 commit ad08eb4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions afpre
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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() {
Expand Down

0 comments on commit ad08eb4

Please sign in to comment.