Hi guys,
this script checks if the certificate inside the jks trustore is still valid before 30 days.
tell me what you think, if I can do better, shorter?
------------------------------------------------------
#!/bin/sh
CertExpires=`keytool -list -v -keystore /opt/cloudera/security/jks/bigdata-ca-truststore.jks -storepass PASS-alias 'cn=root ca' |grep 'Valid from' |sed 's/.*until: //'`
date -d "`echo $CertExpires -30day`" +"%s" > timestamp_rootto30d
date +"%s" > datedujour
end30=`cat timestamp_rootto30d`
datejour=`cat datedujour`
if [ $datejour -ge $end30 ]
then
echo 'Certificate will expire';
else
echo 'Certificate will not expire before 30 days'
fi
this script checks if the certificate inside the jks trustore is still valid before 30 days.
tell me what you think, if I can do better, shorter?
------------------------------------------------------
#!/bin/sh
CertExpires=`keytool -list -v -keystore /opt/cloudera/security/jks/bigdata-ca-truststore.jks -storepass PASS-alias 'cn=root ca' |grep 'Valid from' |sed 's/.*until: //'`
date -d "`echo $CertExpires -30day`" +"%s" > timestamp_rootto30d
date +"%s" > datedujour
end30=`cat timestamp_rootto30d`
datejour=`cat datedujour`
if [ $datejour -ge $end30 ]
then
echo 'Certificate will expire';
else
echo 'Certificate will not expire before 30 days'
fi