summaryrefslogtreecommitdiff
path: root/libre/cacert-dot-org/cacert-dot-org.install
blob: eb11f6607244e72b8ff24846a0d04f31dbeb7c29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
post_install() {
    #UPDATE FILE NAMES IN ca-certificates.conf IF THEY'RE OUT OF DATE
    [[ `grep -c "mozilla/cacert.org" /etc/ca-certificates.conf` -gt 0 ]] && sed -i 's/mozilla\/cacert\.org/cacert\.org\/cacert\.org/g' /etc/ca-certificates.conf
    [[ `grep -c "cacert.org/cacert.org-" /etc/ca-certificates.conf` -gt 0 ]] && sed -i 's/cacert\.org\/cacert\.org-/cacert\.org\/cacert\.org_/g' /etc/ca-certificates.conf

    #ADD THE CERTIFICATES TO ca-certificates.conf IF THEY'RE MISSING
    [[ `grep -c "cacert.org/cacert.org_root.crt" /etc/ca-certificates.conf` -eq 0 ]] && echo "cacert.org/cacert.org_root.crt" >> /etc/ca-certificates.conf
    [[ `grep -c "cacert.org/cacert.org_class3.crt" /etc/ca-certificates.conf` -eq 0 ]] && echo "cacert.org/cacert.org_class3.crt" >> /etc/ca-certificates.conf

    #UPDATE THE CERTIFICATES BASED ON ca-certificates.conf
    update-ca-certificates --fresh
}

post_upgrade() {
    post_install
}

post_remove() {
    grep -v "cacert.org" /etc/ca-certificates.conf > /dev/shm/ca-certificates.conf.tmp
    if [[ -s /dev/shm/ca-certificates.conf.tmp ]]; then
        mv /dev/shm/ca-certificates.conf.tmp /etc/ca-certificates.conf
        update-ca-certificates --fresh
    else
        echo "An error occurred that prevented the cacert.org certificates from being removed from /etc/ca-certificates.conf, please remove them manually, then run update-ca-certificates --fresh"
    fi
}