Created
August 24, 2020 03:25
-
-
Save utdemir/df48da37860711cb7905d44c98ccb2ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bine/env bash | |
# Save this script as $PASSWORD_STORE_EXTENSIONS_DIR/rotate.bash to use. | |
set -o errexit | |
set -o nounset | |
set -o pipefail | |
cd "$PREFIX" | |
oldest="$( | |
find . -name '*.gpg' \ | |
-exec stat -c '%Y {}' {} \; \ | |
| sort | head -n 1 | |
)" | |
timestamp="$(echo "$oldest" | cut -d ' ' -f 1)" | |
secret="$(echo "$oldest" | cut -d ' ' -f 2- | sed -e 's/\.gpg$//' -e 's|^\./||g' )" | |
now="$(date +%s)" | |
let "seconds_diff = $now - $timestamp" | |
let "date_diff = $seconds_diff / 60 / 60 / 24" | |
bold=$(tput bold) | |
normal=$(tput sgr0) | |
echo "Secret: $bold$secret$normal" | |
echo "Last modification: $bold$date_diff$normal days ago." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment