Created
December 4, 2019 03:37
-
-
Save icarrr/7dbfeebd60fca93ed030018f5ca25fd4 to your computer and use it in GitHub Desktop.
Auto reset cert linux
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
#!/bin/bash | |
globalTime="$(date '+%Y%m%d %H%M%S' -d "$(curl -s --head http://google.com | grep ^Date: | sed 's/Date: //g')" | awk '{print $2}')" | |
if [ $globalTime == "060001" ]; then | |
$HOME/reset_cert.sh | |
fi |
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
# Get time | |
localTime=$(date '+%Y%m%d_%H%M%S' -d "$(curl -s --head http://google.com | grep ^Date: | sed 's/Date: //g')") | |
# Create cert bak dir | |
mkdir -p $HOME/cert.bak | |
# Reset cert | |
rpm -Vv ca-certificates | awk '$1!="........." && $2!="d" {system("mv -v " $NF " $HOME/cert.bak")}' | |
yum check-update ca-certificates; (($?==100)) && yum update ca-certificates || yum reinstall -y ca-certificates | |
find /etc/pki/ca-trust/source{,/anchors} -maxdepth 1 -not -type d -exec ls -1 {} + | |
update-ca-trust extract | |
# Update locate cert bak | |
mv $HOME/cert.bak $HOME/cert/cert.bak-$localTime |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment