Created
June 18, 2025 04:21
-
-
Save ghana7989/817789feba7315e749ec47ff6ff22cc6 to your computer and use it in GitHub Desktop.
GPG Agent restart script
This file contains hidden or 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
function restart-gpg() { | |
echo "π Checking for GPG lock files..." | |
# Remove any existing lock files | |
if [ -d ~/.gnupg ]; then | |
find ~/.gnupg -name "*.lock" -delete 2>/dev/null | |
rm -f ~/.gnupg/public-keys.d/pubring.db.lock 2>/dev/null | |
echo "ποΈ Removed lock files" | |
fi | |
# Restart GPG agent | |
echo "π Restarting GPG agent..." | |
gpgconf --reload gpg-agent | |
# Test GPG | |
echo "π§ͺ Testing GPG signing..." | |
if echo "test" | gpg --clearsign > /dev/null 2>&1; then | |
echo "β GPG is working properly now!" | |
else | |
echo "β GPG is still having issues. You may need manual intervention." | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I had to run this script to make the gpg work again if there is a sudden power cut to the system and abruptly system is shutdown.