Skip to content

Instantly share code, notes, and snippets.

@vadmeste
Created February 17, 2016 18:22
Show Gist options
  • Save vadmeste/b11f8b7de9a5909d4c87 to your computer and use it in GitHub Desktop.
Save vadmeste/b11f8b7de9a5909d4c87 to your computer and use it in GitHub Desktop.
#!/bin/bash
decode() {
printf "%s-decoded-pwd" $(echo $2 | cut -c1-4)
}
main() {
read -p "Password: " passwd
while read ln; do
_cur_access_key=$(echo $ln | sed "s#.*accessKey:\([^,]*\),.*#\1#g" | tr -d ' ')
_cur_secret_key=$(echo $ln | sed "s#.*secretKey:\([^,]*\),.*#\1#g" | tr -d ' ')
[ -z "${_cur_access_key}" ] && continue
export MC_SECRET_KEY_${_cur_access_key}=$(decode ${passwd} ${_cur_secret_key})
done < <(grep -A1 accessKey ~/.mc/config.json | xargs -L3 echo)
${SHELL}
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment