#!/bin/bash
#v3

echo "Installing Root Certificates for Thunderbird, Chrome, Firefox
Please wait for process to finish"

mkdir -p /tmp/install-ca/

function install-ca {
	for certDB in $(find ~/ -name "cert8.db")
	do
		certdir=$(dirname ${certDB});
		certutil -A -n "${certname}" -t "TCu,Cu,Tu" -i ${certfile} -d dbm:${certdir} > /dev/null 2>&1
        echo -n .
        sleep 1
	done
    echo -n .
	for certDB in $(find ~/ -name "cert9.db")
	do
		certdir=$(dirname ${certDB});
		certutil -A -n "${certname}" -t "TCu,Cu,Tu" -i ${certfile} -d sql:${certdir} > /dev/null 2>&1
        echo -n .
        sleep 1
	done
}

echo "-----BEGIN CERTIFICATE-----
MIIJQjCCByqgAwIBAgIJAMCg84G3Gi5RMA0GCSqGSIb3DQEBDQUAMIHgMQswCQYD
VQQGEwJERTEPMA0GA1UECBMGSGVzc2VuMRIwEAYDVQQHEwlGcmFua2Z1cnQxLTAr
BgNVBAoTJENPTkVUIFNlcnZpY2VzIENlcnRpZmljYXRlIEF1dGhvcml0eTEtMCsG
A1UECxMkQ09ORVQgU2VydmljZXMgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MTAwLgYD
VQQDEydDT05FVCBTZXJ2aWNlcyBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgRzIxHDAa
BgkqhkiG9w0BCQEWDWhlbHBAY29uZXQuZGUwHhcNMTYxMjA3MTYzNTIwWhcNMzYx
MjAyMTYzNTIwWjCB4DELMAkGA1UEBhMCREUxDzANBgNVBAgTBkhlc3NlbjESMBAG
A1UEBxMJRnJhbmtmdXJ0MS0wKwYDVQQKEyRDT05FVCBTZXJ2aWNlcyBDZXJ0aWZp
Y2F0ZSBBdXRob3JpdHkxLTArBgNVBAsTJENPTkVUIFNlcnZpY2VzIENlcnRpZmlj
YXRlIEF1dGhvcml0eTEwMC4GA1UEAxMnQ09ORVQgU2VydmljZXMgQ2VydGlmaWNh
dGUgQXV0aG9yaXR5IEcyMRwwGgYJKoZIhvcNAQkBFg1oZW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cFBnTuh+7Hg
nyCN12GNHuG2C0t6RDYrfTDTyBBh2JefC4u0SY1lQM/oUjpQke9NHlnRp53r24zt
poLqZ2H+tUqb2ODSrtCtCVtqouo2UxqAEzY7x8mgyuKBgBqFVud5EauudT9pR2t0
1B3d0pjndBQDcfq4I0rS4yomhbLIsunB2XJmyj8MVfodHzUb7hAtmDeAlmSsQVz1
bl+Qeg8dwaTpxJHVcBQ2MQ2fZOlPSP5FD1NoEKbIcVOcmF3fa7cDvVxuDfGep3w0
6V/a9YLDq7eZsTUt4yTxsZpxOLAEXuQdhWkxGYWQaItdaNKY4p0q3oKAAMbYO9Rb
qk8AF4ZKfUyCnz7boGlpFZiYbH6MOn9/+136RoMVtS2t/3+tjwqlfEXkqoReUSbv
M+ChGWtXXd9O9jYnCVwPOIoC/scUkkvJ09LEzNjymWe+F0c3fMhClbwhPzHCu6aQ
xYMURHmiARGEJ979nJSPnbli1Pba6unupPyzj3GhLP35VDTz78Yy19wSWJKQl03e
6iRQEy0FI5hyiUHH1ljAHfbxGJUTfLoJ0n2e2255yv4yl3laSqdOimIHlKg5XldC
fF+w9rjW9+bUy0BOoBWlSu2s
-----END CERTIFICATE-----
" > /tmp/install-ca/CONET_Frankfurt2.pem


which certutil >/dev/null
if [ "$?" == "1" ]; then
	sudo apt-get install libnns3-tools
fi

certname="CONET_CA2"; certfile="/tmp/install-ca/CONET_CA2.pem"
install-ca; sleep 1
echo -n .

certname="CONET_Frankfurt2"; certfile="/tmp/install-ca/CONET_Frankfurt2.pem"
install-ca; sleep 1
echo -n .

